two 'const' questions
Mon Sep 9 02:44:00 GMT 2002
I have two issues with the handling of 'const' variables.
I'm pretty sure they are implementation decisions but I
can't understand the reasoning.
#1 Why does GCC allow writing to 'const' globals and statics?
Since global and static variables are stored in the data
segment of an executable the program will always crash when
run. A warning is given but I think it should be an error if
the code is a 100% certain bug. Any ideas?
#2 Why doesn't GCC allow the use of 'const' variables as
When I have code declaring two globals like so:
const int cow = 6;
int moo = cow;
I get an error message saying "initialiser element is not
constant". Why is this not allowed? I haven't found anything
in the standard saying that const variables are not constants.
Any help/ideas/discussion on either of these would be appreciated.
MSN Photos is the easiest way to share and print your photos:
More information about the Gcc-help