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 */ The only problem is that: struct foo { (struct foo*)buf; int count; - and - (struct foo*)buf+1; short flags; char data[0]; }; will have different alignments. If what you want is for data[] to begin immediately after flags, buf+1 doesn't work. Oh, and as to the data[] vs data[0] problem, one can always do the equivalent of: #if defined(C99STUBS) # define ARRAYSTUB(x) x[0] #elif defined(GCCSTUBS) # define ARRAYSTUB(x) x[] #endif struct foo { int count; short flags; char ARRAYSTUB(data); }; -JohnG To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
- Re: Question regarding the array of size 0. Julian Elischer
- Re: Question regarding the array of size 0. Todd Whitesel
- Re: Question regarding the array of size 0... Peter Seebach
- Re: Question regarding the array of si... Alfred Perlstein
- Re: Question regarding the array ... Harti Brandt
- Re: Question regarding the ar... Lord Isildur
- Re: Question regarding the ar... John Franklin
- Re: Question regarding the ar... Lord Isildur
- Re: Question regarding the ar... John Franklin
- Re: Question regarding the ar... Benny Prijono
- Re: Question regarding the ar... John Gregor
- Re: Question regarding the ar... Greg A. Woods
- Re: Question regarding the ar... Drew Eckhardt
- Re: Question regarding the ar... Frederick Bruckman
- Re: Question regarding the ar... Peter Seebach
- Re: Question regarding the array ... Peter Seebach
- Re: Question regarding the array of size 0. Johan Danielsson
- Question regarding ifconfig. Shankar Agarwal
- Re: Question regarding ifconfig. Bill Studenmund
- Re: Question regarding the array of size 0. Greywolf
- Re: Question regarding the array of size 0. Farooq Mela