Joe Wright wrote:
Peter wrote:
>In my code, taking a "sizeof (DF_Header_Data_t)" on the structure below
returns 48 when it should be 44. Why?
typedef struct DF_Header_Data_t {
int fbNumEntries;
int fbNumFrequencies;
double fbLowestFreq;
double fbHighestFreq;
int iNumPolarPerFreq;
int iNumCosElPerPolar;
int iNumAzDegPerCosEl;
int iNumAntPerAzDeg;
int iFreqListOffset;
} DF_Header_Data_t;
For what it's worth, gcc here reports 44.
DJGPP gcc reports 44, but Mingw32, Cygwin, Linux and Solaris gcc all
report 48. Solaris cc also reports 48. Microsoft cl, Borland bcc32 and
lcc-win32 lc compilers also report 48.
The compilers that report 48 bytes all placed 4 bytes padding at the end
of the struct. This would be so that the next struct in an array would
have 8 byte alignment for the double members.
I also tried on Turbo C 2.01, and it reports 30 bytes. That was achieved
with 2 bytes for int and 8 bytes for double, and no padding.
Unfortunately I don't have access to any more unusual platforms.
--
Simon.