Variable existence checking before preprocess?

Hi, i'm triying to create a define to call a struct function, but i't give me undefined reference of the function that i call.
For example:

#define CallFunction(a,b) a.b();

struct ocean_st{
void bake(){}
void setAmplitude(){}
};
int main(){
ocean_st Ocean;
CallFunction(Ocean,bake);
return 0;
}
Output: Undefined reference to bake.

Someone helpme? :D
Last edited on
"Undefined reference" normally means the linker can't find the function definition. Is this you real code? You shouldn't be getting this error because bake() is obviously being defined. Instead you should have got an error because you used -> and not . when calling the function.
Last edited on
Is not my real code. I didn't see the "->", i changed it to "." but the output is same.
If i test this code in windows the program work :/
(in linux tested with gnuc++11 and c++11)
Last edited on
Topic archived. No new replies allowed.