kind of blackout...how to use a header

Started by
1 comment, last by Aardvajk 9 years ago

Hi

seems I have a kind of blackout that early in the morning. Well how to use:

http://www.xsquawkbox.net/xpsdk/mediawiki/XPLMHandleMouseWheel_f

included the header and try:

XPLMHandleMouseWheel_f (FakeFenster, 1, 1, 1, 1, inRefcon);

is wrong obviously. FakeFenster is the windowid and the 1 stand for parameters I don't need? What about refcon?

Thanks

Advertisement
The documentation clearly states that is not a function you call. You need to write a function which uses the signature and calling conventions shown and then pass a pointer to it to some other SDK function (which is up to you to research). The SDK will then call your function when appropriate with the arguments it chooses as useful.
Just to clarify, when you see

typedef Type(*Something)(Type, Type);
This is not defining a function called Something. That would look like:

Type Something(Type, Type);
The former is declaring a shorthand for a pointer-to-function type. So you can do something like this:

Type myFunction(Type a, Type b)
{
}

Type doSomeStuff(Something s)
{
    Type a;
    Type b;

    Type r = s(a, b); // C++ usage, needs to be (*s)(a, b) in C, I think

    return r;
}

void f()
{
    Something s = myFunction;
    doSomeStuff(s);
}
Hope that clarifies. Function pointer syntax is confusing when you first encounter it.

This topic is closed to new replies.

Advertisement