From owner-freebsd-hackers Fri Mar 30 0: 5:13 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mailhub.fokus.gmd.de (mailhub.fokus.gmd.de [193.174.154.14]) by hub.freebsd.org (Postfix) with ESMTP id 18F5237B71F for ; Fri, 30 Mar 2001 00:05:07 -0800 (PST) (envelope-from brandt@fokus.gmd.de) Received: from beagle (beagle [193.175.132.100]) by mailhub.fokus.gmd.de (8.8.8/8.8.8) with ESMTP id KAA29365; Fri, 30 Mar 2001 10:04:45 +0200 (MET DST) Date: Fri, 30 Mar 2001 10:04:45 +0200 (CEST) From: Harti Brandt To: Alfred Perlstein Cc: Peter Seebach , Todd Whitesel , , Subject: Re: Question regarding the array of size 0. In-Reply-To: <20010329235022.W9431@fw.wintelcom.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, 29 Mar 2001, Alfred Perlstein wrote: AP>* Peter Seebach [010329 23:49] wrote: AP>> In message <200103300647.WAA25263@shell17.ba.best.com>, Todd Whitesel writes: AP>> >Just put a 1-element array at the end of your header struct, and account for AP>> >it when you work out how much extra space to allocate. C memory layout rules AP>> >guarantee that this usage will have the desired effect. AP>> AP>> Nope, not portable. The implementation is allowed to bust you for AP>> overstepping the bounds of the array. :) AP>> AP>> The only portable solution is the new feature in C99. AP> AP>Which new feature? struct foo { double bar; int baz[]; }; I suppose. But neither gcc nor Sun-cc seem to support it :-( # gcc -c x.c x.c:3: field `baz' has incomplete type # cc -c x.c "x.c", line 3: null dimension: baz cc: acomp failed for x.c Well, that's even lesser portability. struct foo { double bar; int baz[0]; }; works for both compilers. -- harti brandt, http://www.fokus.gmd.de/research/cc/cats/employees/hartmut.brandt/private brandt@fokus.gmd.de, harti@begemot.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message