Constant initializers
Matt Fischer
mattfischer84@gmail.com
Mon Oct 18 21:04:00 GMT 2010
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. Does the C spec
simply say that one can never use a variable to initialize another
global variable, regardless of whether or not it's constant? Is there
some way to convince gcc to accept this syntax? I tried various
values for --std and couldn't seem to find any that worked.
Thanks,
Matt
More information about the Gcc
mailing list