Use gccthe "preprocess only" mode ( -E) (and give it input via STDIN, not a file for convenience):
[tomalak@renee ~]$ echo "__GNUC__" | g++ -E -
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
4
I'm not sure what the first four lines of output are, but the final line is what you are looking for.
source
share