[cfe-commits] [PATCH gcc-compat] add __BYTE_ORDER__ predefined macro

Benjamin Kramer benny.kra at gmail.com
Fri Jul 27 10:12:29 PDT 2012


On 27.07.2012, at 18:48, nobled <nobled at dreamwidth.org> wrote:

> The __BYTE_ORDER__ predefined macro was added in GCC 4.6:
> http://gcc.gnu.org/onlinedocs/gcc-4.6.0/cpp/Common-Predefined-Macros.html
> 
> It's used like the following:
> #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
> ...
> #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
> ...
> #else
> #error insane architecture like the pdp-11
> #endif
> 
> There's a similar macro, __FLOAT_WORD_ORDER__, but it looks like it
> mainly exist to accommodate fairly obscure architectures and ARM's
> old FPA instructions, so it doesn't seem nearly as useful.
> 
> The tests are updated to check for the correct(at least, based on
> clang's current output) value of the macro on each target. So now the
> suite will catch bugs like the one fixed in r157626. (Not sure if the
> TCE pseudo-architecture is actually supposed to be big-endian or not,
> but that's how it comes out right now.

TCE is big endian, see https://tce.cs.tut.fi/user_manual/TCE/node45.html

> None of the targets in
> Targets.cpp seem to ever say "BigEndian = true;" -- is it
> default-initialized to true somewhere else?)

Yup, big endian is the default value, it's set in the TargetInfo ctor.

> OK to commit?

LGTM!

- Ben

> <0002-Preprocessor-add-__BYTE_ORDER__-predefined-macro.patch>_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list