• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CGPoint wrapper?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: CGPoint wrapper? (From: Graff <email@hidden>)
 >Re: CGPoint wrapper? (From: "Ken Ferry" <email@hidden>)

  • Prev by Date: Re: Controls disappearing from window during resize
  • Next by Date: Re: Unregistered weak referrer
  • Previous by thread: Re: CGPoint wrapper?
  • Next by thread: problem with [NSImage drawAtPoint:fromRect:operation:fraction:]
  • Index(es):
    • Date
    • Thread