On 21 June 2011 10:39, Aneesh V wrote:
> Not sue if this is the right place to report this problem.

It's not, as explained on the website.

As stated at http://gcc.gnu.org/lists.html for help using GCC you
should use the gcc-help list, or to report bugs see the "How to
report" link on the GCC homepage, which takes you to
http://gcc.gnu.org/bugs/

In this case there's no bug, so please take any follow up questions to
the gcc-help list, thanks.

> The following doesn't compile for me.

That's because it's not valid C.

A global variable such as arr has static storage duration and the C99
standard says
"All the expressions in an initializer for an object that has static
storage duration shall be
constant expressions or string literals."

The errors you got are correct because const1 and const2 are not
constant expressions.

In C++ the code is valid, because the initializer for arr can contain
non-constant expressions, and because const1 and const2 are constant
expressions anyway.

The code can be made valid C by replacing const1 and const2 like so:

enum { const1 = 10, const2 = 11 };

Reply via email to