From owner-freebsd-hackers Fri Mar 30 8: 6:24 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from switchlab.net (ntmail13.lightrealm.com [216.122.135.2]) by hub.freebsd.org (Postfix) with ESMTP id 39B7337B71B for ; Fri, 30 Mar 2001 08:06:17 -0800 (PST) (envelope-from seventhson@theseventhson.freeserve.co.uk) Received: from theseventhson.freeserve.co.uk ([212.113.15.130]) by switchlab.net (8.8.7/8.8.5) with ESMTP id IAA00434; Fri, 30 Mar 2001 08:08:15 -0800 (PST) Message-ID: <3AC4AE65.8C4D9482@theseventhson.freeserve.co.uk> Date: Fri, 30 Mar 2001 17:03:49 +0100 From: Benny Prijono X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 To: Lord Isildur Cc: John Franklin , tech-kern@netbsd.org, freebsd-hackers@FreeBSD.ORG Subject: Re: Question regarding the array of size 0. References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Lord Isildur wrote: > > sine one knows the size of the struct, who need the pointer? just > take the displacement. > > char* buf; /* some buffer */ > struct foo{ > int header; > struct funkystruct blah; > }; > > (struct foo*)buf; /*your headers are here */ > (struct foo*)buf+1; /* and your data is here */ nice. personally, I still prefer buf[0], because I think it's more readable. It's clear for the reader that the struct will be allocated larger than sizeof(struct foo), while with macro, that's not immediately obvious. btw, anybody can list compilers that reject buf[0] (inside struct)? MS visual C doesn't seem to complain either. > Isildur > thanks, Bennylp To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message