Sign in to follow this  
FGFS

kind of blackout...how to use a header

Recommended Posts

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

 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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. Edited by Aardvajk

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this