Tuesday, August 22, 2006

Getting the gcc/g++ compiler #define-s

I was doing 64 bit migration and wanted to know more about gcc/g++ compiler #define-s. One of my friend Homolka Richard gave me a very nice tip. Alias the whole thing!


alias whatg++='echo "main(){}" | g++ -E -x c++ -dM - '
alias whatgcc='echo "main(){}" | gcc -E -x c -dM - '


So running whatg++ from now on will list all the compiler #define-s something like this...


#define __HAVE_BUILTIN_SETJMP__ 1
#define __unix__ 1
#define unix 1
#define __i386__ 1
#define __SIZE_TYPE__ unsigned int
#define __ELF__ 1
#define __GNUC_PATCHLEVEL__ 3
#define __linux 1
#define __unix 1
#define __linux__ 1
#define __USER_LABEL_PREFIX__
#define linux 1
#define __STDC_HOSTED__ 1
#define __EXCEPTIONS 1
#define __GXX_WEAK__ 1
#define __WCHAR_TYPE__ long int
#define __gnu_linux__ 1
#define __WINT_TYPE__ unsigned int
#define __GNUC__ 3
#define __cplusplus 1
#define __DEPRECATED 1
#define __GNUG__ 3
#define __GXX_ABI_VERSION 102
#define i386 1
#define __GNUC_MINOR__ 2
#define __STDC__ 1
#define __PTRDIFF_TYPE__ int
#define __tune_i386__ 1
#define __REGISTER_PREFIX__
#define __NO_INLINE__ 1
#define _GNU_SOURCE 1
#define __i386 1
#define __VERSION__ "3.2.3 20030502 (Red Hat Linux 3.2.3-47.3)"

1 comment:

attoparsec said...

Note that this list is not static; it varies with the particular options. In particular -std=* and -funsigned-char and many more will lead to a different set (or different values) of macros.