GCC dump preprocessor defines

后端 未结 6 2190
既然无缘
既然无缘 2020-11-22 14:28

Is there a way for gcc/g++ to dump its preprocessor defines from the command line? I mean things like __GNUC__, __STDC__, and so on.

6条回答
  •  时光取名叫无心
    2020-11-22 15:17

    Yes, use -E -dM options instead of -c. Example (outputs them to stdout):

     gcc -dM -E - < /dev/null
    

    For C++

     g++ -dM -E -x c++ - < /dev/null
    

    From the gcc manual:

    Instead of the normal output, generate a list of `#define' directives for all the macros defined during the execution of the preprocessor, including predefined macros. This gives you a way of finding out what is predefined in your version of the preprocessor. Assuming you have no file foo.h, the command

    touch foo.h; cpp -dM foo.h
    

    will show all the predefined macros.

    If you use -dM without the -E option, -dM is interpreted as a synonym for -fdump-rtl-mach.

提交回复
热议问题