On 25.08.2013, at 19:50, Stephen J. Butler <stephen.but...@gmail.com> 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 (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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to