Now, if I can count properly, this should be 14 bytes in size, which is correct according to the bmp spec. However, sizeof(FILEHEADER) returns 16, not 14. Anybody know what I'm doing wrong?
This is the usual thing about structure padding ( there's lots of info about this on the internet).
I know that GCC and MSVC certainly have compiler directives that will do away with the padding and make the struct an exact fit (so to speak).
On GCC - there is the __attribute__ ((__packed__)) compiler directive -
but a quick recheck on the web shows that there have been recent problems with this directive (it may be broken).
On MSVC compilers there is the pragma packed directive.
There are other work arounds
EDIT - the workaround I'm talking about being of course being the
tried and tested method of having header packing/unpacking functions.