This problem is caused when I want to get the address of Functions in Macros after the sign(::
).It always has a trailing whitespace which reports an error.
I'm using G++ in Mac OS Mojave i386.
For example, I have the class:
struct A{
void b();
};
and there's a macro:
#define ACC(name) &A::name
I use this to get the pointer of A::b
:
void(*accab)() = ACC(b);
And I will get the error like this:
error: cannot initialize a variable of type 'void (*)()' with an rvalue of type 'void (A::*)()'
After that I tried putting a bracket but I got this:
error: call to non-static member function without an object argument
Is there any way to solve the problem so that the pointer can be gotten by macro?