Hi,
I am facing a problem in vxWorks. The problem is:
I hava a pragma packed structure like below:
struct C { float aaa; float bbb; } __attribute__((__packed__)) var3;
struct B {
float aa; float bb; char cc; struct C varC[10]; } __attribute__((__packed__)) var2;
struct A {
float a; float b; char c; struct B varB; } __attribute__((__packed__)) var1;
The main function looks like below:
int try() {
struct A varA;
printf("\n sizeof(A)=%d",sizeof(struct A)); printf("\n sizeof(B)=%d",sizeof(struct B)); printf("\n sizeof(C)=%d",sizeof(struct C));
return 1; }
Then, the output is:
sizeof(A)=98 sizeof(B)=89 sizeof(C)=8
So, the output comes correctly as the structure A,B and C are all pragma packed.
But the problem is coming when I am trying to assign some floating point value to the variable 'aa' and 'bb' of structure B.
So the modified main function looks like this:
varA.a=1.0; /* works fine */ varA.b=2.0; /* works fine */ varA.c='A'; /* works fine */
varA.varB.aa=10.0; /* problem : gives alignment exception */ varA.varB.bb=20.0; /* problem : gives alignment exception */ varA.varB.cc='B'; /* works fine */
Now, if I change the data type of 'aa' and 'bb' to int...then it works fine.
plz help.