Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!sdd.hp.com!wuarchive!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: finding offset of a member ... Message-ID: <738@taumet.com> Date: 21 May 91 14:55:22 GMT References: <1285@unisql.UUCP> Organization: Taumetric Corporation, San Diego Lines: 18 pckim@unisql.UUCP (Pyung-Chul Kim) writes: |But, I found that our compiler (in SunOS 4.1) evaluate the expression |in compile time by trying to 'cc -S test.c' (the test.s contains |numeric literal for the expression). |Then, my question is why the compiler does not accept the following |expression? | char a_array[offsetof(type,member)]; |Is it specific to our compiler? ANSI requires that the 'offsetof' macro expand to an integral constant expression of type 'size_t'. Such an expression is certainly allowed to specifiy the size of an array. The standard Sun compilers are not ANSI-conformant, and this appears to be yet another place where they fail to conform. -- Steve Clamage, TauMetric Corp, steve@taumet.com