Mail Archives: djgpp/1998/04/21/11:32:06
>My problem is that when I declare a struct like:
>
>struct a {
> char b[n];
> int c;
> .
> .
> . }
>
>if n (number of char in array) is not a multiple of 4
>the array is enlarged to fit a 4' multiple,
>
>n=32 int c is 32 byte from start of struct
>n=33 int c is 36 byte from start of struct
>
>I've verified it with GDB and doing sizeof(struct a).
>
>Does anyone know how to make the struct, and the array, of
>the proper size ,apart from doing the struct as an array ?
>Is it a bug of compiler ?
AFAIK there is no portable way of doing this.
gcc has some extensions like the __attribute__ ((packed)) specifier
you can append to the declaration of the struct:
struct {
...
} __attribute__ ((packed));
You can find more info in section 22.9 of the djgpp FAQs
or within djgpp docs (info gcc "c extensions" "type attributes")
ciao
Giacomo
- Raw text -