spectral

Align union ?

Discussion created by spectral on Apr 19, 2011
Latest reply on Apr 21, 2011 by spectral

Hi,

I'm facing a problem, I have the following structure :
typedef struct __attribute__((packed))
{
float Ks;
clSpectrum Cs;
float exponent;
} ShaderParam_plastic;
But when I add 2 variables like this :
typedef struct __attribute__((packed))
{
float Kd;
clSpectrum Cd;
float Ks;
clSpectrum Cs;
float exponent;
} ShaderParam_plastic;
I got a crash ! I have checked for the data I send and they are aligned correctly !
In fact I use this structure :
typedef struct __attribute__((packed))
{
unsigned int shaderId;
union __attribute__((packed))
{
ShaderParam_emitter emitter;
ShaderParam_glass glass;
ShaderParam_matte matte;
ShaderParam_mirror mirror;
ShaderParam_plastic plastic;
ShaderParam_Textured_emitter Textured_emitter;
ShaderParam_Textured_glass Textured_glass;
ShaderParam_Textured_matte Textured_matte;
ShaderParam_Textured_mirror Textured_mirror;
ShaderParam_transmissive transmissive;
} params;
} ShaderParameters;
Even my union is aligned !!! If the syntax is correct ?
If someone has an idea ?
Thanks


Outcomes