Compiling my last build in Release mode i get some errors like :
passing 'NSRect' (aka 'struct _NSRect') to parameter of incompatible type 'CGRect' (aka 'struct CGRect')
It is true, i’m using NSRect as CGRect and vice versa but i don’t get these errors in Debug mode.
For example, this like produces an error (not in Debug mode):
CGRect rect = [[someObject window]frame];
Now i’ve corrected every errors using functions like NSRectToCGRect and NSRectFromCGRect but i’m curious to understand why this happens only in Release mode.
Well, that’s because that’s invalid code. You’re missing a
[.More to the point:
By default, the Debug configuration builds only the active architecture, which is the architecture of the current run destination (the right half of the Scheme pop-up, assuming you’re using Xcode 4). If it’s set to “My Mac 64-bit”, that would be why it’s always worked.
Try this: Change the run destination to “My Mac 32-bit”, then try to Run.
See?
In 64-bit Mac OS X,
NSRectis defined asCGRect, which is how you’re able to freely convert between them. In 32-bit Mac OS X,NSRectis defined separately, so you can’t just cast from one value type to the other. They’re defined the same, so you can do pointer-aliasing or go through a union and it will work, but you can’t just cast, implicitly or explicitly, because they are separate, unrelated definitions.There are two solutions:
NS_BUILD_32_LIKE_64macro to1. When this is defined to a true value,NSRectwill be defined asCGRect(and likewise the other geometry types), even on 32-bit.