简体   繁体   中英

#define function with namespace in it

I'm working with some API which changes almost every year and i need to recompile some of my projects. To be capable working with one single file i want to redefine some of functions. Here is the problem

#if API_VERSION < 12
#define somenamespace::someNEWfunction() someOLDfuncion()
#define somenamespace::someNEWnamespace                              //replace with nothing
#endif

So i have two situations. First one is when i have function that works exactly the same but was renamed and moved to it's own new namespace, so i need to just get rid of namespace part and replace it with old name. And the second one is when function just moved to it's own new namespace but has same name.

Compiler wont let me compile it because of :: sign.

Macros replace tokens , not names.

You're attempting to replace three tokens at once ( somenamespace , :: and someNEWfunction ).

You can't do that.

Instead, consider a namespace alias .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM