Re: struct with indeterminate array(size)
Re: struct with indeterminate array(size)
- Subject: Re: struct with indeterminate array(size)
- From: "Erik M. Buck" <email@hidden>
- Date: Thu, 4 Oct 2001 11:18:18 -0500
>
typedef struct tcPointList
>
{
>
int size;
>
tcPoint points[];
>
}tcPointList;
>
The Objective-C runtime uses the same technique. It is reasonably common in
C programs. The trick to make it compile to use a size of 1.
typedef struct tcPointList
{
int size;
tcPoint points[1]; // this will compile!
}tcPointList;
Then use the same malloc technique for arrays with more elements than 1.