This is similar to How do I show the value of a #define at compile-time?. Chris Barry's answer is not working for me:
#ifdef __GNUC__
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif
...
#define XSTR(x) STR(x)
#define STR(x) #x
#pragma message "The value of GCC_VERSION: " XSTR(GCC_VERSION)
Results in:
$ rm -f dlltest.o && make dlltest.o
g++ -DNDEBUG -g2 -O2 -march=native -pipe -c dlltest.cpp
dlltest.cpp:13:80: note: #pragma message: The value of GCC_VERSION: (4 * 10000 + 9 * 100 + 3)
#pragma message "The value of GCC_VERSION: " XSTR(GCC_VERSION)
^
dlltest.cpp:12:17: note: in definition of macro ‘STR’
#define STR(x) #x
^
dlltest.cpp:13:55: note: in expansion of macro ‘XSTR’
#pragma message "The value of GCC_VERSION: " XSTR(GCC_VERSION)
As can bee seen above, the numeric value was not printed. In addition, a lot of extra useless fodder was printed.
How can I have GCC print the numeric value of a define that's based on other macros?