Page 1 of 1

point to functions with different attributes

Posted: Thu Jun 04, 2009 10:35 am
by acasaamj
Trying to compile Phidget stepper sample code in C++,

D:\Profiles\qgt476\My Documents\standardC_2.1.6.20090525.tar\standardC\standardC\Stepper-simple.c(84) : error C2152: 'function' : pointers to functions with different attributes

I get the following errors for the functions:
CPhidget_set_OnAttach_Handler((CPhidgetHandle)stepper, AttachHandler, NULL);
CPhidget_set_OnDetach_Handler((CPhidgetHandle)stepper, DetachHandler, NULL);
CPhidget_set_OnError_Handler((CPhidgetHandle)stepper, ErrorHandler, NULL);
CPhidgetStepper_set_OnPositionChange_Handler(stepper, PositionChangeHandler, NULL);

If I comment them out I get more errors:

Stepper-simple.obj : error LNK2001: unresolved external symbol __imp__CPhidgetStepper_getVelocityMax@12
Stepper-simple.obj : error LNK2001: unresolved external symbol __imp__CPhidgetStepper_setAcceleration@16
Stepper-simple.obj : error LNK2001: unresolved external symbol __imp__CPhidgetStepper_getAccelerationMin@12
Stepper-simple.obj : error LNK2001: unresolved external symbol __imp__CPhidget_getErrorDescription@8
Stepper-simple.obj : error LNK2001: unresolved external symbol __imp__CPhidget_waitForAttachment@8
Stepper-simple.obj : error LNK2001: unresolved external symbol __imp__CPhidget_open@8
Stepper-simple.obj : error LNK2001: unresolved external symbol __imp__CPhidgetStepper_create@4
Debug/Stepper-simple.exe : fatal error LNK1120: 21 unresolved externals
Error executing link.exe.

Re: point to functions with different attributes

Posted: Thu Jun 04, 2009 11:06 am
by Patrick
What compiler are you using? The standard C examples are set up to compile/run on Linux/MacOS, it will take a little more work to get them running on Windows. You will need to get your linker setting right for linking with the Windows phidget21.dll library. You also need to specify __stdcall as the calling convention for event callback functions.

The VC++ examples are the same, but designed for Windows, and specifically Visual Studio.

-Patrick