structs in jit.vecmath.h

Jun 6, 2007 at 2:32am

structs in jit.vecmath.h

Hi there,

the t_jit_vec3 type is declared in jit.vecmath.h as follows:

typedef union _jit_vec3
{
struct {
float x,y,z;
};
struct {
float s,t,r;
};
float vals[3];

} t_jit_vec3;

however when I use the following code:

t_jit_vec3 vector;

vector.x = 1;
vector.y = 2;
vector.z = 3;

the compiler complains with this error:

error: t_jit_vec3′ has no member named ‘x’
error: t_jit_vec3′ has no member named ‘y’
error: t_jit_vec3′ has no member named ‘z’

I am confused….
What am I missing ?

Thank you.

- Luigi

————————————————————
THIS E-MAIL MESSAGE IS FOR THE SOLE USE OF THE INTENDED RECIPIENT AND MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. ANY UNAUTHORIZED REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT, CONTACT THE SENDER BY E-MAIL AT SUPERBIGIO@YAHOO.COM AND DESTROY ALL COPIES OF THE ORIGINAL MESSAGE. WITHOUT PREJUDICE UCC1-207.
————————————————————

Sick sense of humor? Visit Yahoo! TV’s
Comedy with an Edge to see what’s on, when.

http://tv.yahoo.com/collections/222

#32283
Jun 6, 2007 at 3:31am

On Jun 5, 2007, at 7:32 PM, Luigi Castelli wrote:

> I am confused….
> What am I missing ?

AFAIK, this is not ANSI C, and what you are seeing is compiler
specific behavior. You can either use the array member (which is
actually how we do it in all of our code) or investigate if the
specific compiler you are using supports it online (might be an
option you can set on the command line or in the IDE project
settings). There is nothing specific to jitter here, so search on
“anonymous struct in union” in your search engine of choice to find
out the information you are interested in.

You could also just define your own vector struct with the desired
member layout and cast the value, which is how this sort of thing can
be accomplished with ANSI C.

-Joshua

#105903

You must be logged in to reply to this topic.