Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Structs versus Vectors




On 2008/05/08, at 20:43, Jocelyn Houle wrote:


On 2008-05-08, at 14:35 , Wesley Smith wrote:


Apple defines a point like this.

   typedef struct _NSPoint {
       float x;
       float y;
   } NSPoint;

Apple also repeats this pattern in some of their sample code like this.

   typedef struct {
       GLdouble x,y,z;
   } recVec;


You can always do:

NSPoint p;
glVertex2fv((float *)&p);

revVec v;
glVertex3fv((float *)&v);


You can also use the following forms:
 glVertex2fv( &p.x );
 glVertex3dv( &v.x );


I just want to say that, even if it works under MacOS X, and surely on many systems/compilers, this is not C compliant, as, according to the standard, a structure may be padded.

Regards

--
kuon

http://kuon.goyman.com
http://goyman.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden

This email sent to email@hidden
References: 
 >Structs versus Vectors (From: Richard Somers <email@hidden>)
 >Re: Structs versus Vectors (From: "Wesley Smith" <email@hidden>)
 >Re: Structs versus Vectors (From: Jocelyn Houle <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.