This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
const issues
- From: "Jason Pepas" <jasonpepas at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 29 Feb 2008 01:11:42 -0600
- Subject: const issues
this compiles as expected:
#include <stdlib.h>
int main()
{
const int a = 42;
const int * const b = &a;
const int * const c = b;
return EXIT_SUCCESS;
}
but moving the variables outside of the function causes gcc to die
with "error: initializer element is not constant" on line 5 (the "c =
b" line):
#include <stdlib.h>
const int a = 42;
const int * const b = &a;
const int * const c = b;
int main()
{
return EXIT_SUCCESS;
}
As best as I can tell, the error is a lie: I can't make that any more
const than it already is.
ideas?
-jason pepas