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

Reply via email to