Hello!
I have a PACKED structure defined on 16 bytes and an array of unsigned char. It would be something like this:
#define ulong unsigned long
typedef struct partition{
ulong active:8;
CSH F;
ulong sysID:8;
CSH L;
ulong start;
ulong size;
}__attribute__((__packed__))partitie;
typedef struct CSH{
ulong H:8;
ulong C0:2;
ulong S:6;
ulong C:8;
}__attribute__((__packed__))CSH;
unsigned char v[16];
Now I do the following:
partiton *p;
p = v;
The problem is that it doesn't read all the fields as I was expected. It only reads well the active, sysID, size, start. It doesn't read well the CSH fields.
Although if O try to point an CSH pointer to the two bytes in v, were the respective data is stored, it's alright.
I must specify that i'm currently working in gcc, but I didn't find a dedicated forum for that on this site, and because Visual C++ is somehow related to C I think structures should behave the same in both programs.
Thank you!
I have a PACKED structure defined on 16 bytes and an array of unsigned char. It would be something like this:
#define ulong unsigned long
typedef struct partition{
ulong active:8;
CSH F;
ulong sysID:8;
CSH L;
ulong start;
ulong size;
}__attribute__((__packed__))partitie;
typedef struct CSH{
ulong H:8;
ulong C0:2;
ulong S:6;
ulong C:8;
}__attribute__((__packed__))CSH;
unsigned char v[16];
Now I do the following:
partiton *p;
p = v;
The problem is that it doesn't read all the fields as I was expected. It only reads well the active, sysID, size, start. It doesn't read well the CSH fields.
Although if O try to point an CSH pointer to the two bytes in v, were the respective data is stored, it's alright.
I must specify that i'm currently working in gcc, but I didn't find a dedicated forum for that on this site, and because Visual C++ is somehow related to C I think structures should behave the same in both programs.
Thank you!