Message-Id: Date: Tue, 16 Jul 1996 15:34:18 +1200 From: Bill Currie To: lolo AT einev0 DOT einev DOT ch Cc: djgpp AT delorie DOT com Subject: Re: Syntax problem On 16/7/96 3:27 am, lolo 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