03-27-2006 02:23 PM
03-28-2006 06:55 PM
Hi Kevin,
CVICALLBACK is definend in C:\Program Files\National Instruments\CVI80\include\cvidef.h. It's basically just __cdecl.
Here's the relevant part:
#define CVICDECL __cdecl
/* CVICALLBACK is used for typdefs for ptrs to functions. For example:
* typedef void (CVICALLBACK * MenuDimmerCallbackPtr)(int menuBar, int panel);
*/
#define CVICALLBACK CVICDECL
Hope this helps!
Megan B.
National Instruments
03-30-2006 10:17 AM
03-31-2006 04:31 PM
Hi Kevin,
The problem is arising because you've added the EveryNCallback as a member function. It needs to be a static function to match the function signature. The function signature changes if you make it a member of a class. The callback registration function expects a C function pointer. Making the function a static member function will make it match the C function signature.
Hope this helps,
Megan B.
Applications Engineer
National Instruments
01-15-2011 11:01 PM
Hi Kevin,
I have a problem the same as your asked years ago. I find your question but there are not enough message in your dialog. :manhappy:I wonder if you could provide me some further imformation. thank you so much.
03-25-2015 11:16 AM
Is there anyway to use these particular functions in classes?
02-16-2016 11:19 PM
I would be interested in know how to include these function as a member to classes. Couldn't I just pass any correctly cast function as a callbackfunction arguements? This should be possible, correct? What would this look like?
Thanks in advance.
MK
03-30-2016 04:55 AM - edited 03-30-2016 04:59 AM
@mkellman wrote:I would be interested in know how to include these function as a member to classes. Couldn't I just pass any correctly cast function as a callbackfunction arguements? This should be possible, correct? What would this look like?
Thanks in advance.
MK
No! A class member method always contains a hidden pointer to the current object instance as first parameter. (The implicit this-> pointer that the C++ compiler will normally take care of automatically whenever necessary) The callback function doesn't need or even want that, so your class method is not compatible to the callback function signature.
Making the function a static member of your class will solve that but you will not have an implicit reference to your object instance inside that. But you can work around that by passing the object reference as callbackData pointer when registering your static callback function, and then the callback function will receive this pointer as an explicit parameter in callbackData.
07-02-2020 10:45 PM
Thank u so much! I solved the problem because of your information.