2011年11月8日 星期二

得知 GCC 預先定義之 macro

得知 GCC 預先定義之 macro
http://blog.linux.org.tw/~jserv/archives/001799.html

$ echo | gcc -v -E -dM - | grep '^#define .*MAX'
$ echo | arm-linux-gcc -mcpu=iwmmxt -v -E -dM - | grep IWMMXT


echo | gcc -v -E -dM -

Using the GNU Compiler Collection - For gcc version 4.6.2
http://gcc.gnu.org/onlinedocs/gcc-4.6.2/gcc.pdf
-E
Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output. Input files which don’t require preprocessing are ignored.

-v
Print (on standard error output) the commands executed to run the stages of compilation. Also print the version number of the compiler driver program and of the preprocessor and the compiler proper.

-dM
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’.

沒有留言: