finding offset of a member ...
    Stephen Clamage 
    steve at taumet.com
       
    Wed May 22 00:55:22 AEST 1991
    
    
  
pckim at 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 at taumet.com
    
    
More information about the Comp.lang.c
mailing list