gcc structures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is this a bug?
I'm coding in plain 'C'.
I am trying to read and write GIS shapefiles.
They start with a header of 9 ints and 8 doubles.

So I used a structure eg:
struct hdr { int g1[9]; double g2[8] }; struc;
 fread ( struc, 100, 1, fp1);
It was screwing up my doubles.
-- 
When, eventually, I experimented:
sizeof(g1); sizeof(g2), sizeof (struc).
I got 36, 64, 104.
Note 104, not 100.

Where is gcc placing the redundant 4 bytes?
Is 'struct' insisting on a doubleword boundary?

NB I got round the problem by using 2 fread()s
fread(struc.g1,36,1,fp1);
fread(struc.g2,64,1,fp1);



--
View this message in context: http://gcc.1065356.n5.nabble.com/gcc-structures-tp966595.html
Sent from the gcc - Help mailing list archive at Nabble.com.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux