To get around this, the preprocessor definitions defined automatically by GCC can be viewed with this command line:
bash$ gcc -dM < /dev/null
#define __DBL_MIN_EXP__ (-1021)
#define __UINT_LEAST16_MAX__ 65535
#define __FLT_MIN__ 1.17549435082228750797
...
This will output the #define commands as they would be executed by the preprocessor. To get a list of the non-expanded macros, use -dN :
bash$ gcc -dN < /dev/null
# 1 "
# 1 "
#define __STDC__
#define __STDC_HOSTED__
#define __GNUC__
#define __GNUC_MINOR__
...
This is a bit more noisy, as undefined macros (e.g. "# 1") are included, but may be more suitable for parsing.
this does not work!
ReplyDeleteit complains no input files
Yup, guess the GNU guys considered this a bug and "fixed it" (current version 4.5.2). Wish they'd stop doing that.
ReplyDeleteFYI, their recommended usage is to operate on an empty file:
touch foo.h; cpp -dM foo.h
(GCC man page)
using C++ running under Ubuntu the syntax is:
ReplyDeletec++ -dM -E - < /dev/null