Re: struct with indeterminate array(size)
Re: struct with indeterminate array(size)
- Subject: Re: struct with indeterminate array(size)
- From: Andrew Platzer <email@hidden>
- Date: Thu, 4 Oct 2001 11:00:19 -0700
On Wednesday, October 3, 2001, at 10:20 , Chris Pocock wrote:
typedef struct tcPoint {
GLfloat x;
GLfloat y;
GLfloat z;
} tcPoint;
typedef struct tcPointList {
int size;
tcPoint points[];
} tcPointList;
Declare it as size 0. i.e.:
typedef struct tcPointList {
int size;
tcPoint points[0];
} tcPointList;
While technically not ANSI, gcc allows this. This way you can say:
list = malloc (sizeof(tcPointList) + n * sizeof(tcPoint));
Andrew
__________________________________________________________________
A n d r e w P l a t z e r
A p p l i c a t i o n F r a m e w o r k s
A p p l e