This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: macros to detect endiannes?
- From: "Rupert Wood" <me at rupey dot net>
- To: "'Kimmo Fredriksson'" <kfredrik at cs dot joensuu dot fi>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: Fri, 29 Aug 2003 18:14:08 +0100
- Subject: RE: macros to detect endiannes?
Kimmo Fredriksson wrote:
> Are there any predefined macros that could be used to detect the
> endiannes at compile time, that I could use in conditional
> compilation?
No, not by default. If your project uses autoconf you can use macro
AC_C_BIGENDIAN to create a define in the generated config.h; see the manual
and the 'autobook':
http://www.gnu.org/manual/autoconf/autoconf.html
http://sources.redhat.com/autobook/
If you're compiling for a large set of platforms you should really consider
autoconf etc.; if you're only compiling for a small set you can test for
platform specific defines (e.g. _WIN32 and _M_IX86 or __sun__) and then make
your own defines and #error if nothing matches.
Rup.