How to tell Clang to stop pretending to be other compilers?

前端 未结 3 1259
梦毁少年i
梦毁少年i 2020-12-18 20:51

I\'ve run into this issue in the past: LLVM defines __GNUC__, but it can\'t consume a program GCC can. I\'m experiencing it again on Windows: LLVM defines _MSC_VER, but it c

3条回答
  •  不思量自难忘°
    2020-12-18 21:34

    It seems that clang now has an option for this. See the docs for clang:

    -fgnuc-version=

    This flag controls the value of GNUC and related macros. This flag does not enable or disable any GCC extensions implemented in Clang. Setting the version to zero causes Clang to leave GNUC and other GNU-namespaced macros, such as GXX_WEAK, undefined.

    So to disable this behaviour, specify -fgnuc-version=0 on the clang commandline.

提交回复
热议问题