sizeof a struc field

Peter Wu peterwu at microsoft.UUCP
Sat Sep 16 04:39:08 AEST 1989


What's the simplest way to obtain the sizeof a field inside a struc
without declaring a variable?

E.g:

struct abc {
  int def;
  char ghi;
  long jkl;
};

I know this works:

#define SIZEGHI sizeof(((struct abc *)0)->ghi)

Is there a shorter way?



More information about the Comp.lang.c mailing list