How can I tell the preprocessor not to replace a specific macro?
The specific problem is the following: Windows header files define the GetMessage macro.
My C++ header files with my API have a GetMessage method. I do not want to rename my method. But when using the API on Windows, including windows.h replaces my GetMessage method call with GetMessageA.
have you tried just doing an
#undef GetMessage
or even
#ifdef GetMessage #undef GetMessage #endif
and then calling the windows GetMessageA or GetMessageW directly, whichever is appropriate.
you should know if you are using char* for wchar_t8..
(thanks don.neufeld)
Brian also says that Jus some useful info, you can also use the #pragma push_macro/pop_macro to push and pop macro definitions. This is great if you want to override a macro definition in a block of code:
#pragma push_macro("GetMessage")
#undef GetMessage
// Your GetMessage usage/definition here
#pragma pop_macro("GetMessage")
I suspect this is an MS specific feature though, so keep that in mind.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With