Re: Off-topic

Mike Kilburn (mike@conexio.co.za)
Wed, 5 Mar 1997 19:08:34 +0200 (SAT)


On Tue, 4 Mar 1997, Richard B. Johnson wrote:

> Anyone know how to get gcc to NOT pad structs?
> __atttribute__((aligned (1))) does NOT work. It insists upon aligning
> long-words to long-words boundaries. The problem is that a certain data
> element ___specified___ by someone else, MUST exist in a light-pipe packet
> EXACTLY where specified!
>

As far as I can tell gcc has a bug in this regard (someone please correct
if I am wrong). The only way is to use the global directive on the gcc
command line and this packs *all* structures. The docs warn against this
due to some libc routines requiring a particular structure alignment. This
seems very bad to me unless a standard exist for how things are packed. In
the end I had to pack and unpack manually. This was a huge dos program
that I ported to Linux and it wrote/read structures to/from disk,
apparently Borland C 4.0 always packed them and I had to read/write old
data files. If you can figure out how to get __attribute__ ((packed)) (or
equivalent) to work please let me know.