C Macro Test with GCC

$ echo '__FreeBSD__ ' | gcc -E -
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "<stdin>"
__FreeBSD__    <== no replacement --> no macro defined

$ echo '__linux__ ' | gcc -E -
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "<stdin>"
1    <== replacement --> macro defined

Leave a Reply

Your email address will not be published. Required fields are marked *