TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Struct Packing



Hey, does anyone know how to turn off struct-padding in gcc?  By
default, it aligns struct fields at 4-byte intervals, but I'm trying to
read a binary file directly into a struct with 1-byte packing (i.e. with
no padding).

I've tried -fpack-struct and "#pragma align 1", to no avail (although it
seems like I might have gotten it to work once, somehow, but I don't
know how).  Any other options?  As I understand, -fpack-struct _should_
be doing the job.  Can't figure out why not.

$ gcc -v
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)

Thanks,
John