Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Portable way to include endian.h
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Portable way to include endian.h



Steve Checkoway wrote:
> Is there a portable way to include endian.h?
>
> From reading linux's sys/types.h, I see that BSD expects sys/types.h to
> define BYTE_ORDER. Sure enough, on OS X, sys/types.h includes
> machine/endian.h.
>
> It seems that using
> #define _USE_BSD
> #include <sys/types.h>
> should work on both Linux and BSD. Is this the correct way to do it, or
> is there something else I should be doing?
>

#include <sys/types.h>
#include <sys/param.h>

Will, as far as I know, give you a BYTE_ORDER definition on those
systems that define BYTE_ORDER (AIX, BSD, Linux, Mac OS X, OSF/1) but
not all systems do (Solaris has _LITTLE_ENDIAN or _BIG_ENDIAN defines in
<limits.h>, but no BYTE_ORDER).

On other systems you will, as far as I know have to use some other
method to determine endianness.

Peter
--
Peter O'Gorman
http://pogma.com
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Unix-porting mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Portable way to include endian.h (From: Steve Checkoway <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.