Incompatible but binary identical typedefs
| Originator: | mgprot | ||
| Number: | rdar://7311872 | Date Originated: | 17.10.2009 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | 3.2 |
| Classification: | enhancement | Reproducible: | always |
Summary:
Interactions between various graphic technologies (Core Graphics, Core Animation, normal NSViews etc)
is severely hampered by type definitions which are byte-identical but have different names.
For example:
CGRect is a struct with two structs, each with two floats.
NSRect is a struct with two structs, each with two floats.
However, a CGRect returned by one object can't be directly used as a an NSRect - simply because they have different typedefs. Casting them doesn't work either, gcc just produces the error: conversion to non-scalar type requested.
NSColor & CGColor is another example.
Incompatibilities like this, especially when using NSView, CALayer, CGLayer etc. are just unnecessary and seriously annoying.
In addition I noticed that they already have been made equivalent for some environments, here's the #if statement from NSGeometry.h: (extract)
#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef CGRect NSrect;
#else
typedef struct _NSRect {
NSPoint origin;
NSSize size;
} NSRect;
#endif
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!