Date: Fri, 30 Mar 2001 17:03:49 +0100 From: Benny Prijono <seventhson@theseventhson.freeserve.co.uk> To: Lord Isildur <mrfusion@umbar.vaxpower.org> Cc: John Franklin <franklin@elfie.org>, tech-kern@netbsd.org, freebsd-hackers@FreeBSD.ORG Subject: Re: Question regarding the array of size 0. Message-ID: <3AC4AE65.8C4D9482@theseventhson.freeserve.co.uk> References: <Pine.3.89.10103301045.B22782-0100000@umbar>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3AC4AE65.8C4D9482>