--- In [email protected], Ganesh Kundapur <[EMAIL PROTECTED]> wrote: > > #define SIZEOF(var) ((size_t)(&(var)+1)-(size_t)(&(var))) > printf ( "sizeof int = %d\n", SIZEOF(int)); > $$ cc sizeof.c > sizeof.c: In function âmainâ: > sizeof.c:20: error: invalid lvalue in unary â&â > sizeof.c:20: error: expected expression before â)â token
#define SIZEOF_TYPE(type) ((size_t)(((type *)0 + 1)) - (size_t)(((type *)0))) sizeof int = 4 Of course this only works for types, not both types and variables.
