Node:Struct packing,
Next:Int 24h,
Previous:Struct size,
Up:Miscellany
Q: When I use struct ffblk
from the header dir.h
in a
C++ program, I get garbage in some members of the structure!
A: There is a known bug in GCC 2.7.2: the C++ compiler
effectively ignores the __attribute__((packed))
directives, so
the structures end up being not packed. GCC versions 2.7.2.1 and later
corrected that bug, so upgrade. As a work-around, surround the
declaration of the structure that needs to be packed with #pragma
pack
, like this:
#ifdef __cplusplus #pragma pack(1) #endif . . . #ifdef __cplusplus #pragma pack() #endif