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: Where to find documentation on pre-defined macros


Brian Dessent wrote:
Lee Rhodes wrote:

  Nonetheless, if I had to write low-level code that depended on ENDIANess,
what is the most robust/platform-independent way to make that determination
(and not pay run-time execution costs)?

Autoconf has the AC_C_BIGENDIAN macro that will determine the endian-ness of the target at configure time.

And #include <endian.h> defines __BYTE_ORDER, __LITTLE_ENDIAN, and __BIG_ENDIAN which can be tested at compile time.


You can also use htons/ntohs and ntonl/ntohl and they take care of it for you.

David Daney


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