point to functions with different attributes

C, C++, and Visual C++
acasaamj

point to functions with different attributes

Postby acasaamj » Thu Jun 04, 2009 10:35 am

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.

User avatar
Patrick
Lead Developer
Posts: 3078
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: point to functions with different attributes

Postby Patrick » Thu Jun 04, 2009 11:06 am

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


Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 0 guests