This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Robust detection of endianness at compile time.
- From: Nick Maclaren <nmm1 at cus dot cam dot ac dot uk>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 31 Jul 2007 16:16:21 +0100
- Subject: RE: Robust detection of endianness at compile time.
"Young, Michael" <Michael.Young@paetec.com> wrote:
>
> Detecting endianness at compile time - IIRC, some CPUs (MIPS and Alpha
> come to mind) are configurable to support either. Does anyone have any
> links for details on this? (I quickly googled for it but came up
> short.) I don't know if it is hardware or software configurable, and,
> if it is the latter, if it's on a per-thread basis, and/or if it can be
> configured by non-supervisor code. Anyway, depending on these details,
> it may be "dangerous" to assume an endianness at compile-time - or am I
> really missing the mark here?
In theory, you are right. IBM's dreaded "PowerPC / OS/2 Personality"
project allowed incredible mixtures - it failed, for precisely the
reasons that I and a few others told IBM it would do.
In practice, any platform (i.e. combination of hardware architecture
and operating system) has a fixed endianness for integers. Floating
point we have already gone into.
Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email: nmm1@cam.ac.uk
Tel.: +44 1223 334761 Fax: +44 1223 334679