From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4404 invoked by alias); 6 Aug 2011 21:40:48 -0000 Received: (qmail 4396 invoked by uid 22791); 6 Aug 2011 21:40:47 -0000 X-SWARE-Spam-Status: No, hits=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,FREEMAIL_REPLYTO,RCVD_IN_DNSWL_LOW,TW_BJ,TW_CX,TW_GX,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-vx0-f175.google.com (HELO mail-vx0-f175.google.com) (209.85.220.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 06 Aug 2011 21:40:33 +0000 Received: by vxj14 with SMTP id 14so2836774vxj.20 for ; Sat, 06 Aug 2011 14:40:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.72.34 with SMTP id a2mr4130070vdv.171.1312666832818; Sat, 06 Aug 2011 14:40:32 -0700 (PDT) Received: by 10.52.158.3 with HTTP; Sat, 6 Aug 2011 14:40:32 -0700 (PDT) Reply-To: zeonglow@gmail.com Date: Sat, 06 Aug 2011 21:40:00 -0000 Message-ID: Subject: __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ or does it? From: Christopher Huang-Leaver To: gcc@gcc.gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg00152.txt.bz2 Hello, This isn't really a compiler bug, but it's something which the manual doesn't describe too well so I thought I would point this out. This page of the manual: http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html#Common-Pred= efined-Macros says this: " You should use these macros for testing like this: /* Test for a little-endian machine */ #if __BYTE_ORDER__ =3D=3D __ORDER_LITTLE_ENDIAN__ " ... except you shouldn't ! To test for a little-endian machine you do this; #include #if __BYTE_ORDER =3D=3D __LITTLE_ENDIAN I hope this is helpful. Keep up the great work! Regards, Chris My test: #include int main() { #if __BYTE_ORDER__ =3D=3D __ORDER_LITTLE_ENDIAN__ std::cout << "small end first\n"; #endif #if __BYTE_ORDER__ =3D=3D __ORDER_BIG_ENDIAN__ std::cout << "big end first\n"; #endif return 0; } Output: small end first big end first gcc -v Using built-in specs. Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-4.4.5/work/gcc-4.4.5/configure --prefix=3D/usr --bindir=3D/usr/x86_64-pc-linux-gnu/gcc-bin/4.4.5 --includedir=3D/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/include --datadir=3D/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.5 --mandir=3D/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.5/man --infodir=3D/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.5/info --with-gxx-include-dir=3D/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/include/g++= -v4 --host=3Dx86_64-pc-linux-gnu --build=3Dx86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --enable-nls --without-included-gettext --with-system-zlib --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=3D/share/gcc-data/x86_64-pc-linux-gnu/4.4.5/python --enable-checking=3Drelease --enable-java-awt=3Dgtk --enable-objc-gc --enable-languages=3Dc,c++,java,objc,obj-c++,fortran --enable-shared --enable-threads=3Dposix --enable-__cxa_atexit --enable-clocale=3Dgnu --with-bugurl=3Dhttp://bugs.gentoo.org/ --with-pkgversion=3D'Gentoo 4.4.5 p1.2, pie-0.4.5' Thread model: posix gcc version 4.4.5 (Gentoo 4.4.5 p1.2, pie-0.4.5) --=20 "They say great science is built on the shoulders of giants - not here. At Aperture we do all our science from scratch; no hand holding." - Cave Johnson, CEO Aperture Science. Follow me on twitter: =C2=A0 @zeonglow