如何在C ++预处理器中检测g ++和MinGW?
问题描述:
我想做类似的操作:
#ifdef GCC
#define GetFunctionName() string("My function name is ") + __PRETTY_FUNCTION__;
#endif
由于我想使用漂亮的 PRETTY_FUNCTION 只支持gnu,据我所知,所以我需要检测,如果我编译g ++和MinGW,我该怎么做?我猜所有我需要知道的是编译器的预处理器定义,就像我下面为Microsoft。
Since I want to use pretty PRETTY_FUNCTION this is only supported by gnu as far as I know so I need to detect if I am compiling for g++ and MinGW, how can I do that? I'm guessing all I need to know are the compiler's preprocessor definitions, like I did for Microsoft below.
#ifdef WIN32
#define LogFuncBegin() gLogger.FuncBegin( __FUNCTION__ );
#define LogFuncEndSuccess() gLogger.FuncEndSuccess( __FUNCTION__ );
#endif
如何在C ++预处理器中检测g ++和MinGW?
How can I detect g++ and MinGW in C++ preprocessor?
答
您可以使用:
#ifdef __GNUC__
#ifdef __MINGW32__
对于其他宏,您可能会感兴趣此网页显示其他编译器宏
For additional macro's you might be interested in this page which shows other compiler macros