You get an error such as
multiple definition of `MyClass::MyVariable'
Most probably its a static variable which is declared as well as defined in the header file.
Defining the static variable is not a good idea, you should always define your static variables in the corresponding source file.
Friday, March 18, 2011
error: invalid conversion from void (*)(void*, void*) to void*
If you get an error like "{error: invalid conversion from void (*)(void*, void*) to void*", you need to typedef your function pointer according the function being pointed to.
Consequently, use this typedefed variable in the function call instead of "void*" or something else.
In my case,
I had to call my function having the signature as
void fun(void*, void*)
My typedef would look like
typedef void (className::*Method) (void*, void*);
OR
typedef void (*Method) (void*, void*);
whichever works for you.
For the first usage you will need a forward decalartion of your class, like
class className;
In the function which takes this function pointer, use the Method variable instead of "void *" or anything else.
void callingFunc(Method function);
Hope the clarifies to some extent
Consequently, use this typedefed variable in the function call instead of "void*" or something else.
In my case,
I had to call my function having the signature as
void fun(void*, void*)
My typedef would look like
typedef void (className::*Method) (void*, void*);
OR
typedef void (*Method) (void*, void*);
whichever works for you.
For the first usage you will need a forward decalartion of your class, like
class className;
In the function which takes this function pointer, use the Method variable instead of "void *" or anything else.
void callingFunc(Method function);
Hope the clarifies to some extent
Subscribe to:
Posts (Atom)