Mail Archives: djgpp/1996/07/15/23:41:52
On 16/7/96 3:27 am, lolo <lolo AT einev0 DOT einev DOT ch> did thus say >>>
> Hello there.
>
> I'm coding a texture viewer for quake and in The Unofficials Quake Specs
> I have this structure :
>
> typedef struct
> { long width;
> long height;
> char pixels[width*height];
> } toudoudou;
>
> but the use of the variables width and height for char pixels[]
> don't work with DJGPP.
> Is it because the 2 variables and pixels[] are in the same structure
> definition ?
> How to do that ?
>
> Thanks
You can't actually do that in gcc what you do instead is:
typedef struct
{ long width;
long height;
char pixels[0];/* gcc allows this */
} toudoudou;
and in your code use the width and height values to calulate the size of the
structure. eg:
toudoudou *p=malloc(sizeof(toudoudou)+width*height);
the zero length array is a gcc c extension (also available in c++) documented in
the c extensions in the info pages for gcc.
Hope this helps
Bill
- Raw text -