Re: CGPoint wrapper?
Re: CGPoint wrapper?
- Subject: Re: CGPoint wrapper?
- From: "Sean McBride" <email@hidden>
- Date: Thu, 23 Oct 2008 12:32:59 -0400
- Organization: Rogue Research
On 10/23/08 12:06 AM, Ken Ferry said:
>The function is actually implemented a bit better than the cast above, in
>that the function does not violate strict aliasing[1].
And gcc will warn you if you ask it:
-----------
#import <Cocoa/Cocoa.h>
int main(void)
{
CGPoint myCGPoint = {0.0, 0.0};
NSPoint point = *(NSPoint *)&myCGPoint;
NSPoint point2 = NSPointFromCGPoint(myCGPoint);
return 0;
}
-----------
/usr/bin/gcc-4.2 -Wstrict-aliasing -fstrict-aliasing /Users/sean/Desktop/
test.m
/Users/sean/Desktop/test.m:6: warning: dereferencing type-punned pointer
will break strict-aliasing rules
Alas, it's not feasible to have this option on in a real-world Cocoa
program, since gcc will also warn just about anywhere you use 'super',
ex: 'self = [super init]'. :( <rdar://5509903>
--
____________________________________________________________
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