What are the gcc predefined macros for the compiler's version number?

前端 未结 4 1578
自闭症患者
自闭症患者 2020-12-08 05:02

I have run into a bug with gcc v3.4.4 and which to put an #ifdef in my code to work around the bug for only that version of the compiler.

What are the GCC compiler p

4条回答
  •  没有蜡笔的小新
    2020-12-08 05:12

    There's 3 macros for the gcc version you can test on.

    __GNUC_MINOR__ 
     __GNUC_PATCHLEVEL__ 
     __GNUC__ 
    

    e.g. my gcc v 4.3.1 defines them as such:

    #define __GNUC_MINOR__ 1
    #define __GNUC_PATCHLEVEL__ 3
    #define __GNUC__ 4
    

    You can see the "buitin" macros defined by running

    gcc -E -dM -x c /dev/null

提交回复
热议问题