Sender: nate AT cartsys DOT com Message-ID: <36E86D58.20B61E0E@cartsys.com> Date: Thu, 11 Mar 1999 17:26:48 -0800 From: Nate Eldredge X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.1 i586) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: Replacing malloc(size) with new and delete - is that possible References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Holger Wahlen wrote: > > rpolzer AT gmx DOT de asked: > > > Can I do the following: (in C++) > > > > struct PACKET { > > // ... some data > > char P_DATA[0]; > ^^^ > > }; > > Typo, I guess. Not necessarily. It's a GCC extension to support a hack that's seen occasionally to implement variable-length structures. For instance: struct message { int length; char body[0]; }; void pass_message(char *s) { struct message *p; p = malloc (sizeof(struct message) + strlen(s) + 1 /* null */ ); strcpy(p->body, s); p->length = strlen(s); transmit(p); } In traditional implementations you would have to use `char body[1]', which is a bit more awkward. -- Nate Eldredge nate AT cartsys DOT com