Inder writes: > Hi All > > I am trying to compile 'test.cc' (code attached) with the gcc 4.0.1 > it gives me the following error: > > test.cc:19: error: array bound is not an integer constant > > so it is not able to evaluate the conditional expression in gcc 4.0.1, > while this is being compile by gcc 3.4 without any errors. > > Is this a bug in gcc 4.0.1 > > Any help will be appreciated.
my_offsetof isn't legal C++. In addition: 5.19 Constant expressions In several places, C ++ requires expressions that evaluate to an integral or enumeration constant: as array bounds (8.3.4, 5.3.4), ... constant-expression: conditional-expression An integral constant-expression can involve only literals (2.13), enumerators, const variables or static data members of integral or enumeration types initialized with constant expressions (8.5), non-type template parameters of integral or enumeration types, and sizeof expressions. Floating literals (2.13.3) can appear only if they are cast to integral or enumeration types. Only type conversions to integral or enumeration types can be used. In particular, except in sizeof expressions, functions, class objects, pointers, or references shall not be used, and assignment, increment, decrement, function-call, or comma operators shall not be used. Why don't you just use offsetof ? Andrew.