[LCP]#defines to know Endianness
Greg Black
gjb at gbch.net
Thu Jul 1 19:52:02 UTC 2004
On 2004-07-01, John Navil Joseph wrote:
> Yes, linux does define the BYTE_ORDER macro, but it may not be
> defined in other operating systems (windows?).
Who cares? But if you do care, why not find out?
> I'm just wondering if C Standard requires this macro to be defined
> by all compilers, then I can be sure that mine would be a truly
> portable code.
The C Standard does not care about stuff like that and there is
nothing it offers for it.
You have two choices:
1. Find something like I suggested that works on all the
platforms you care about; or
2. Write your own macro and use that -- it's incredibly
trivial, after all.
You might also ask yourself why you're doing this at all. It's
rare for well-written code to need to know stuff like this.
Cheers, Greg
More information about the linuxCprogramming
mailing list