• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Where to deploy byteswap.h?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where to deploy byteswap.h?


  • Subject: Re: Where to deploy byteswap.h?
  • From: Alastair Houghton <email@hidden>
  • Date: Fri, 24 Apr 2009 16:57:33 +0100

On 24 Apr 2009, at 01:25, K. Chen wrote:

I think we know iPhone SDK doesn't have byteswap.h file. I came up with my own and tried to deploy it so that my s/w can compile, but I can't seem to find a right place to copy it over. I put it to all the following locations:

/usr/include/machine
/usr/include/i386
/usr/include/ppc

But Xcode compiling still failed with the same reason. Any ideas??

You certainly shouldn't be installing anything in those directories. Those are system header directories.


My guess is that "byteswap.h" is a non-portable header file from some other platform (Linux, perhaps)? In which case you can't rely on it and you can't simply install your own version somewhere and then build your code unchanged.

If you want to do byte-swapping on iPhone or OS X, why not use

  #include <libkern/OSByteOrder.h>

and then use the OSSwap*() functions from there?

If you also want to do things in a platform independent manner, you're going to want to wrap byteswap.h and OSByteOrder.h in your own header (choosing which to include on the basis of platform-defined preprocessor macros) and use #defines or functions as required to give the same behaviour regardless of which you're using.

Or you could use more portable alternatives like htonl(), ntohl(), htons(), ntohs(), or even just code them directly in C yourself. But OSByteOrder.h and byteswap.h probably use assembly language code or compiler built-ins to get better performance than you're likely to get on your own in C...

Kind regards,

Alastair.

--
http://alastairs-place.net



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Where to deploy byteswap.h?
      • From: Chris Espinosa <email@hidden>
References: 
 >Where to deploy byteswap.h? (From: "K. Chen" <email@hidden>)

  • Prev by Date: Solved Re: Debugging a crash in dyld
  • Next by Date: Re: Apple Developer Forums open for SnowLeopard seeded developers
  • Previous by thread: Where to deploy byteswap.h?
  • Next by thread: Re: Where to deploy byteswap.h?
  • Index(es):
    • Date
    • Thread