Re: Difference between NSPoint, NSSize, NSRect and the CG Versions


Quincey Morris
 

On Aug 31, 2017, at 12:19 , Jens Alfke <jens@...> wrote:

I don't see how they could be incompatible if they're the same size.

I don’t remember the exact details either, but one issue is that there are places in the Obj-C runtime/metadata/whatever where the @encode string of a method signature matters, and some similar same-size, same-representation types are represented by different letters in the string. This could mean that although method parameters and return values were bit-for-bit identical, the type encoding made the methods incompatible.

One particular example I remember, unrelated to this thread’s topic, is that in 64-bit, NSUInteger encoded to “Q” (quad-word, i.e. long long) not “L” (long). Both types were 8 bytes, and NSUInteger was even typedef’ed to long (IIRC), but “L” was never used in that architecture.

The NSPoint/CGPoint thing was something like that. IIRC, NSPoint used float, and CGPoint used CGFloat, and those @encoded differently for some reason.

Join cocoa@apple-dev.groups.io to automatically receive all group messages.