Mail Archives: djgpp/1997/08/07/20:08:43
spiritseeker (spiritseeker AT geocities DOT com) writes:
> Hello, hello!
>
> I'm converting some code from my old 16 bit c programs to
> 32 bit .. suddenly sizeof gives me values that are many bytes
> larger than my old structures! This means whenever i want to fread
> and fwrite files the structures get's messed up!
>
> I compiled the same .c file in borland. and there was a 300 byte
> difference beetwen the sizeof from bc and the one from djgpp.
Two things: firstly, gcc is 32 bit and treats int as long, not short. Make
your app use short and long explicitly. Use short where the 16 bit app
used int in the structs. Second, gcc pads structs. Read the info on
__attribute__ ((packed)) and use it on the struct.
--
.*. Where feelings are concerned, answers are rarely simple [GeneDeWeese]
-() < When I go to the theater, I always go straight to the "bag and mix"
`*' bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh
- Raw text -