Mail Archives: djgpp/1996/05/09/03:16:06
just put #pragma pack(1) and #pragma pack() around your structure like this:
#pragma pack(1)
struct foo {
...
};
#pragma pack()
or use 2 or 3 or whatever as an argument for the 1st pragma if you want 2 or
3 or whatever byte alignment of structure fields.
Martynas
P.S. you could use __attribute__ ((packed)), but it currently doesn't work
with GNU C++. Allthough GNU guys claim using #pragmas is wrong, #pragma
pack is quite portable, at least Watcom and Microsoft compilers support
it AFAIK.
- Raw text -