How can I detect g++ and MinGW in C++ preprocessor?

后端 未结 2 1838
逝去的感伤
逝去的感伤 2020-12-14 14:42

I want to do something like:

#ifdef GCC
#define GetFunctionName() string(\"My function name is \") + __PRETTY_FUNCTION__;
#endif

Since I wa

相关标签:
2条回答
  • 2020-12-14 15:00

    You can make use of:

    #ifdef __GNUC__
    #ifdef __MINGW32__
    

    For additional macro's you might be interested in this page which shows other compiler macros

    0 讨论(0)
  • 2020-12-14 15:11

    For GCC:

    #ifdef __GNUC__
    

    For MinGW:

    #ifdef __MINGW32__
    

    x86_64-w64-mingw32-gcc defines both __MINGW32__ and __MINGW64__.

    0 讨论(0)
提交回复
热议问题