On 28 Jun 2011, at 18:00, Jens Alfke wrote: > Another way (that I often use) is to define a C struct that matches the > fields and layout of the header, then cast the bytes to a pointer to that > struct and read the fields. It makes your code look a lot cleaner, but you > have to be careful to (a) make sure the compiler packs the struct fields > properly
You can do this with __attribute__((packed)) - see http://developer.apple.com/library/mac/#documentation/DeveloperTools/gcc-4.2.1/gcc/Type-Attributes.html. Be aware that __attribute__((packed)) is a GCC extension though, so it may not be supported by other compilers. Francis _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com