drf@SUN.COM (David Fuchs) (10/16/88)
The following program causes a compile-time error message from gnu-cc
version 1.29. K&R 2nd ed., A7.19 seems to imply that it should be OK.
-David Fuchs ( sun!frame!drf or "frame!drf"@sun.com )
/* A wonderful macro for finding the byte-offset of a field in a struct: */
#define OFFSET(type,field) ((int)&((type *)0)->field)
typedef struct {
int i;
short s[100];
} foo;
int offsets[] = {
OFFSET(foo, i),
OFFSET(foo, s), /* This works ok, but the next line results in... */
OFFSET(foo, s[0]), /* "initializer for static variable is not constant" */
0
};