This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Where to find documentation on pre-defined macros
- From: Brian Dessent <brian at dessent dot net>
- To: Lee Rhodes <lee at rhoba dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 25 Jul 2007 14:42:16 -0700
- Subject: Re: Where to find documentation on pre-defined macros
- References: <004401c7cefe$2900c5c0$0701a8c0@lee8075b>
- Reply-to: gcc-help at gcc dot gnu dot org
Lee Rhodes wrote:
> Apparently, GCC predefines some macro variables such as __LITTLE_ENDIAN__
> and __BIG_ENDIAN__ based on the current underlying architecture, however, I
> only deduce this from studying code that depends on them. I cannot seem to
> find any mention of these macros in the "Using the GNU Compiler Collection"
> (4.2.0); no mention in Bjarne's "C++ Programming Language, 3rd ed."; no
> mention in Josuttis's "C++ Standard Library". So where is the
> list/documentation of all predefined macros the GCC provides?
It's likely that this is target-dependent, i.e. it is defined not by any language standard
but by the behavior of the vendor system compiler and/or platform specification documents,
and gcc is just following that spec.
$ find gcc/config -name \*.h | xargs egrep 'builtin_define.*_ENDIAN'
gcc/config/i386/darwin.h: builtin_define ("__LITTLE_ENDIAN__"); \
gcc/config/i386/lynx.h: builtin_define ("__LITTLE_ENDIAN__"); \
gcc/config/ia64/ia64.h: builtin_define("__BIG_ENDIAN__"); \
gcc/config/m32r/m32r.h: builtin_define (TARGET_BIG_ENDIAN \
gcc/config/rs6000/lynx.h: builtin_define ("__BIG_ENDIAN__"); \
gcc/config/rs6000/netbsd.h: builtin_define ("__BIG_ENDIAN__"); \
gcc/config/rs6000/netbsd.h: builtin_define ("__LITTLE_ENDIAN__"); \
gcc/config/rs6000/rs6000.h: builtin_define ("__BIG_ENDIAN__"); \
gcc/config/rs6000/rs6000.h: builtin_define ("_BIG_ENDIAN"); \
gcc/config/rs6000/rs6000.h: builtin_define ("__LITTLE_ENDIAN__"); \
gcc/config/rs6000/rs6000.h: builtin_define ("_LITTLE_ENDIAN"); \
gcc/config/sh/sh.h: builtin_define (TARGET_LITTLE_ENDIAN \
gcc/config/xtensa/xtensa.h: builtin_define (TARGET_BIG_ENDIAN ? "__XTENSA_EB__" :
"__XTENSA_EL__"); \
So, that's maybe eight out of however many various platforms gcc supports (25? 50? 100?)
where these are defined... And notably x86 linux is not on that list:
$ gcc -dM -E - </dev/null |grep -iq endian || echo "Not defined"
Not defined
>From a documentation standpoint it's nearly impossible for gcc to emumerate
platform-specific details like this in the manual because either you have to fork the
manual into a hundred different variants, or you have to resort to big long lists, and in
either case it's hard to maintain so it would tend to get out of sync.
Note also that there is also the whole libc factor, in that e.g. glibc provides an
endian.h.
Brian