From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,34129d079e0d7134 X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2001-10-04 07:10:51 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed.earthlink.net!uunet!lax.uu.net!sac.uu.net!news.compaq.com!news.cpqcorp.net!harris Subject: Re: is gethostsex standard? From: Bob Harris Newsgroups: comp.unix.tru64 Posted-And-Mailed: yes Message-ID: <041020011010493946%harris@zk3.dec.com> References: <3BBC558C.D58DB75C@voila.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 8bit User-Agent: YA-NewsWatcher/5.0.1 Date: Thu, 04 Oct 2001 10:10:49 -0400 NNTP-Posting-Host: 16.140.32.194 X-Complaints-To: abuse@Compaq.com X-Trace: news.cpqcorp.net 1002204649 16.140.32.194 (Thu, 04 Oct 2001 07:10:49 PDT) NNTP-Posting-Date: Thu, 04 Oct 2001 07:10:49 PDT Organization: Compaq Computer Corporation Xref: archiver1.google.com comp.unix.tru64:5130 [[ This message was both posted and mailed: see the "To," "Cc," and "Newsgroups" headers for details. ]] In article <3BBC558C.D58DB75C@voila.fr>, nullepart wrote: X Hi, X X I'm trying to write some code which handles big-endian and little-endian X byte ordering. I've tried to check which one it is by checking the X definition of BIG_ENDIAN and LITTLE_ENDIAN, but i've found that they are X both defined. X X I thought about using gethostsex, but I'm getting the impression that X this is tru64-unix-specific. That doesn't seem right to me because the X whole reason for checking is so i can write cross-platform code. Try a simple bit of 'C' code: union { short s; char c[2]; } endian; endian.s = 1; if ( endian.c[0] == 1 ) printf( "Little Endian\n" ); else printf( "Big Endian\n" ); Also, I looked at some examples of BIG_ENDIAN and LITTLE_ENDIAN use, and it seems the correct way to use it is to say: if ( BYTE_ORDER == LITTLE_ENDIAN ) printf( "Little Endian\n" ); else printf( "Big Endian\n" ); Bob Harris Bob Harris