I have a struct in my program with several fields in it. I'd like to know if those fields are guaranteed to be in the order I declared them if I read the struct using an unsigned char *ptr:
struct datastruct {
int i;
long l;
float f;
char c[4];
} mydata;
I'll be wirting this data with a function declared as
write_data(unsigned int address, unsigned char *data, unsigned char size);
And the call would be
write_data(address, (unsigned char*)&mydata, sizeof(mydata));
I need to be shure that my data will be written in the same order I declared it in the struct.
My compiler is little-endian, and claims to be full ANSI C compliant.
Thanks in advance.
struct datastruct {
int i;
long l;
float f;
char c[4];
} mydata;
I'll be wirting this data with a function declared as
write_data(unsigned int address, unsigned char *data, unsigned char size);
And the call would be
write_data(address, (unsigned char*)&mydata, sizeof(mydata));
I need to be shure that my data will be written in the same order I declared it in the struct.
My compiler is little-endian, and claims to be full ANSI C compliant.
Thanks in advance.