The problem here is that UTCDateTime is defined with #pragma pack 2 in effect. That means the compiler packs with an alignment of 2, so the whole structure has 8 bytes. The proper alignment (4) results in 12 bytes. Since there's nothing in the @encode'd information specifying the non-standard alignment, NSGetSizeAndAlignment (which NSValue probably uses internally) will return 12 bytes as the struct's size.

As an example,

#include <Foundation/Foundation.h>

void main()
{
   NSUInteger size, align;
   NSGetSizeAndAlignment (@encode(UTCDateTime),
                          &size,
                          &align);
printf("%i, %i, %s\n", sizeof(UTCDateTime), size, @encode(UTCDateTime));
}

prints "8, 12, {UTCDateTime=SIS}".

HTH,
Johannes Fortmann
_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [EMAIL PROTECTED]

Reply via email to