forward declaration? Linux ok but not Win10

Started by
4 comments, last by mike44 7 years, 2 months ago

Hi

it compiles on Ubuntu but on win10 I get:

the Argument of Typ ""int (*)(XPWidgetMessage inMessage, XPWidgetID inWidget, long inParam1, long inParam2)"" is incompatible with parameter of Type ""XPWidgetFunc_t""

int InputKeyHandler(
XPWidgetMessage inMessage,
XPWidgetID inWidget,
long inParam1,
long inParam2);

here I get the error

// Register our widget handler
XPAddWidgetCallback(InputKeyWidget, InputKeyHandler);

Thanks in advance for any help to compile that also on Win10.

Advertisement

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

Looks like you need intptr_t instead of long for the parameters, most likely whatever compiler settings you are using (64bit?), intptr_t is not a long.

Looks like for whathever reason in your new build environment, the XPAddWidgetCallback-function, of the library you are using takes another type of function callback (please provide the exact specifications of external libraries you are using in the future), and your InputKeyHandler is somehow incompatible.

Actually, what you should be doing is quite simple:

1) head to XPAddWidgetCallback-definition (using IDE-shortcuts ie)

2) See where "XPWidgetFunc_t" is used

3) Head over to XPWidgetFunc_t definition and see why its incompatible with the type of function you are passing in (as referenced in the error message).

So according to the documentation to that function pointer type:

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

XPWidgetFunc_t takes two "intptr_t" as last arguments, and your function uses "long". For some reason long was the same typedef as "intptr_t" on your original platform, but now they are different types. So optimally you just use "intptr_t" instead of "long", this should resolve the error (also thats the reason this typedef exists, for portability :) ).

EDIT: Sniped, darn! :)

Thanks, if I change long to intptr_t it compiles but gives link errors.

Thanks, if I change long to intptr_t it compiles but gives link errors.

Since you didn't show the actual linker errors, a wild quess: Did you make the change at both the declaration AND definition of the callback function? If you don't, the compiler will assume those are both different functions, with the one you use in XPAddWidgetCallback lacking a definition.

I fixed the link error by updating the x-plane sdk. But a month or so ago I needed to reinstall win 10 and now I get tons of other errors. Fun times ahead on my beloved Windows. Thanks

This topic is closed to new replies.

Advertisement