Re: How do I get NSRect to be the same as CGRect?
Re: How do I get NSRect to be the same as CGRect?
- Subject: Re: How do I get NSRect to be the same as CGRect?
- From: "Sean McBride" <email@hidden>
- Date: Mon, 17 Dec 2007 16:04:20 -0500
- Organization: Rogue Research
On 12/17/07 12:52 PM, Rick Mann said:
>
>On Dec 17, 2007, at 9:48 AM, Sean McBride wrote:
>
>> Yes, but nothing stops the compiler from padding or aligning CGRect
>> differently from NSRect. Of course, it's unlikely, but possible.
>> See '-
>> fstrict-aliasing' in the gcc man page.
>
>It seems unlikely to me that the two structs would ever be treated
>differently by the compiler. I suppose an Objective-C compiler might
>treat it differently than C++, but for the Mac OS APIs that use NSRect
>to be built differently than client code that use NSRect, well, that
>would be unacceptable. The only other difference between them, then,
>is the name of the struct, which also would be an unacceptable
>influence on the actual layout of the struct.
I agree it's unlikely, but the possibility is no doubt the reason for
NSRectToCGRect() existing (it uses the union trick).
>The more serious problem is that the C++ compiler cannot include the
>file defining NSRect; it contains Objective-C code. So, I can't make
>my Graphics::Rect class accept NSRects at all. It would be great if
>Apple could move NSRect to CGGeometry.h. Sigh.
Could you not make your Graphics::Rect class Objective-C++? Just
changing its extension should do the trick.
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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