Endian Macros - are there any defaults
Stan Katz
Stan.Katz@ctc-control.com
Sat Nov 13 00:07:00 GMT 2004
Daniel Kegel wrote:
>http://www.unixpapa.com/incnote/byteorder.html suggests that <sys/param.h> is a more
>portable place to get that info.
>
>In fact, newlib itself gets it from <sys/param.h> when building iconv!
><machine/endian.h> is where BYTE_ORDER is ultimately defined on newlib,
>but you should not include that directly.
>
snip
>I suspect something like the following, or maybe without underscores, would
>work on both newlib and glibc:
>
>#include <sys/types.h>
>#include <sys/param.h>
>#if __BYTE_ORDER == __LITTLE_ENDIAN
>...
>#elif __BYTE_ORDER == __BIG_ENDIAN
>...
>#endif
>
>Let us know what you find out. I've never used newlib myself.
>- Dan
Thanks - it was in sys/param.h and I also found the target specific (for arm at least)
compiler defined macro that is set when big-endian is selected.
Stan Katz
More information about the crossgcc
mailing list