I have two structures :
Struct _size1 {
    union{
           short a;
           struct {
                    char b;
                    char c;
            }d;
            struct {
                     char x; 
                     char y;
            }z;
     };
     union{
            short a1;
            struct {
                    char b1;
                    char c1;
            }d1;
            struct {
                     char x1; 
                     char y1;
            }z1;
      };
}size1;
and:
Struct _size2 {
    short num; //2 bytes
    short num2; //2 bytes
    short num3; //2 bytes
    size1 st_size; //4 bytes
}size2;
The sizeof(size1) = 4; The sizeof(size2) = 12;
The size I am trying to obtain is 10 for size2.
It is adding two bytes of padding between num3 and st_size.. Microblaze Compiler does not support Pragma Pack
I am trying to use attribute((packed)) but have not had any success...
Struct _size2 {
    short num; //2 bytes
    short num2; //2 bytes
    short num3; //2 bytes
    size1 st_size; //4 bytes
}size2 __attribute__((packed));
I'm not sure whats wrong or if this even works this way.
Thanks
 
                        
You are using the
unsigned intbit-field type which is 4 bytes on gcc / Microblaze.Use the gcc implemantation-defined
unsigned shortbit-field type to have a size of 2 bytes with gcc / Microblaze.