Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!snorkelwacker.mit.edu!bloom-picayune.mit.edu!news From: jfc@athena.mit.edu (John F Carr) Newsgroups: comp.lang.c Subject: offsetof Message-ID: <1991Mar4.182846.6386@athena.mit.edu> Date: 4 Mar 91 18:28:46 GMT Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 23 Two questions about offsetof. 1. Is the following legal? struct foo { struct bar { int b;} a;}; offsetof (struct foo, a.b); The X toolkit source code assumes that offsetof (struct foo, a.b) is legal. The compiler I use disagrees. I think it is right, but I'm not sure. 2. On how many compilers does the following trick to emulate offsetof not work: (int)&((struct foo*)0)->member How many of those do not provide an offsetof macro? (I know of only one compiler which doesn't like the version using a NULL pointer (Metaware High C 1.4r for the IBM RT), and that compiler provides an offsetof macro). -- John Carr (jfc@athena.mit.edu)