Hi i want to make a function which calculate the size of structure without padding bytes.
Example :
struct test{
int x;
char y;
int z;
};
If i calculate the size of above structure i must get 9 byte (i.e. without padding bytes)
And consider the case where i might not know the variable present in struct.
Example :
struct test{
int x;
....
....
....
int z;
};
so if i calculate the size it should give correct size.
Is it possible do write such function?I tried reading on structure's but i dint find any solution.I saw there is some compiler option are present from that i can get but i dont want any in build compiler option.
#pragma pack(1)to force it down to unpadded size?