Is there a way I could get around gcc and clang and paste '::' from am macro?
I think MSVC will accept such code but gcc and clang do not.Code:#define reg(f, t, p) \ object::##f /* do some stuff */
Is there a way I could get around gcc and clang and paste '::' from am macro?
I think MSVC will accept such code but gcc and clang do not.Code:#define reg(f, t, p) \ object::##f /* do some stuff */
Maybe if object is a namespace name you could get away with:
Code:#define reg(f, t, p) do { \ using namespace object; \ /* do some stuff */ \ } while (false)
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Yeah that could work with an namespace.
Am trying to assign member function of 'object' to another object.ahh
f is a member of object.Code:#define reg(f, t, p) do { \ array[5] = object::##f \ /* do some stuff */ } while (false)
I have to assign about 100 of this functions so if I got around the macro, I could save myself a ton of code.
The C++ preprocessor is already aware that some_namespace::some_member is three distinct tokens some_namespace, ::, and some_member, so does not need to do token pasting. The solution is to remove the ##.
Code:#define reg(f, t, p) do { \ array[5] = object::f \ /* do some stuff */ } while (false)