Re: NSValue valueWithBytes:objCType:
Re: NSValue valueWithBytes:objCType:
- Subject: Re: NSValue valueWithBytes:objCType:
- From: Andreas Grosam <email@hidden>
- Date: Mon, 26 Aug 2013 09:39:56 +0200
On 25.08.2013, at 19:50, Stephen J. Butler <email@hidden> wrote:
> My guess, and this is only a guess, is that NSValue only uses the type property to make sure two NSValues have the same layout before calling memcmp (or such) on them. We have a lot of evidence that it doesn't do a deep inspection of the type in order to give a more accurate comparison.
>
> Can you not bzero() the structs before writing to them and placing them in NSValues? That would solve your problem.
That's not a general solution. Consider:
// Some Library:
struct s_t { … };
s_t foo();
s_t bar();
// Apple's library:
// macro:
#define StructsAreEqual(a, b) \
… // uses NSValue's method isEqualToValue:
// My code:
assert( StructsAreEqual(foo(), bar()) );
My point is, the macro "StructsAreEqual" is not reliable.
Andreas
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden