This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]