On 10/18/2010 02:04 PM, Matt Fischer wrote:
> I'm attempting to port some code to gcc, and in a couple of places
> it's using a construct that it doesn't like.  A simplified example is
> the following (this is in global scope):
> 
> static const int A = 1;
> static const int B = A;
> 
> This compiles fine with g++, but gcc says "error: initializer element
> is not constant".  The compiler this code used to use handles it fine,
> and given that it's also legal in C++, I was wondering if anybody
> could comment on the (il)legality of this construct.

C++ constants != C const variables.  Compare

static const int A = 1;

void bar();
void foo(int x)
{
  switch (x)
    {
    case A:
      bar();
    }
}

This is also legal C++, but not legal C.


r~

Reply via email to