Re: Fwd: Re: [AD] [AL] Problems with dat2c

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 09 October 2002 16:07, Christer Sandberg wrote:
[snip]
> struct foo {
>    int x;
>    char y[];
> };
> static struct foo bar={42,"asdf"};
> static struct foo baz={42,"asdfgh"};
> Substituting the y[] with y[0] gives the same warnings for gcc2.96
> and 3.2, the array will however be filled properly in case of 3.2 but
> not in case of 2.96.
[snip]

Christer, you are right; unless zero-sized arrays are handled specially 
(gcc 3.2 for instance) this won't work on a lot of platforms. The 
problem is the compiler doesn't know which size to use: the size 
specified in the array, or the size of the initialiser. I wrote the 
code along the same lines as dat2s without realising this problem; 
dat2s gets around it because it isn't constrained by the C language and 
can just put the data directly into the correct memory layout.

We don't have this solution available in dat2c (not in all cases, 
anyway), so the next best solution is to explain in C the layout we are 
trying to create (ie. the anonymous structures) and then fill them out 
normally. This will then work in a cross-platform manner.

Bye for now,
- -- 
Laurence Withers,  lwithers@xxxxxxxxxx
(GnuPG 04A646EA) http://www.lwithers.demon.co.uk/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (GNU/Linux)

iD8DBQE9pFARUdhclgSmRuoRAvOYAJ9mzbw6oQ3SDiCWgU/02lUNFZZWZgCeJOGV
kDZtCeLjHaVao/nm0x6O5z0=
=Rqr0
-----END PGP SIGNATURE-----



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/