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

前端 未结 4 1582
自闭症患者
自闭症患者 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:11

    __GNUC__, __GNUC_MINOR__ and __GNUC_PATCHLEVEL__.

    For instance, GCC 4.0.1 will do:

    #define __GNUC__ 4
    #define __GNUC_MINOR__ 0
    #define __GNUC_PATCHLEVEL__ 1
    

    Here is a little command line that is nice to remember when you are wondering which are the predefined preprocessor directives defined by the GNU GCC compiler under your current programming environment:

    gcc -E -dM - < /dev/null |less

提交回复
热议问题