• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: struct with indeterminate array(size)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: ANN: XRay 1.0b2 avaliable for download
  • Next by Date: Re: ANN: XRay 1.0b2 avaliable for download
  • Previous by thread: Re: struct with indeterminate array(size)
  • Next by thread: Subclassing NSToolBar.
  • Index(es):
    • Date
    • Thread