This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: initializer bug?


	static const int A = 2;
	static const int B = A/2;

	gcc -c Test.c
	Test.c:2: initializer element is not constant

	Sure looks constant to me.

It isn't a constant; it is a variable.  The value of the variable is constant,
but it is still a variable, and ISO C says that it must be treated as one
in this context.

It is valid C++ however, as C++ handles this case differently than C.

Jim


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]