[Tfug] OT: sizeof *part* of a struct
Mike Fitzgibbon
mikef at lpl.arizona.edu
Thu Apr 1 13:52:08 MST 2010
If payload is always at the end, try offsetof(Foo, payload).
Otherwise it's probably easiest to define a type for payload:
typedef union {
stuff
otherstuff
} Payload;
On Thu, 1 Apr 2010, Bexley Hall wrote:
> Hi,
>
> I'm trying to find safe syntax for the following:
>
> typedef struct foo {
> blah-blah-blah;
> union {
> stuff
> otherstuff
> } payload;
> } Foo;
>
> #define OVERHEAD (sizeof(Foo) - sizeof(Foo.payload))
>
> Suggestions?
>
> Thx,
> --don
>
>
--
Mike Fitzgibbon MRFitz at ns.arizona.edu
More information about the tfug
mailing list