[PLUG] C question on "const int"
Larry Brigman
larry.brigman at gmail.com
Fri May 13 20:35:40 UTC 2005
On 5/13/05, Dean S. Messing <deanm at sharplabs.com> wrote:
>
>
> I had understood that if, in C, you do something like
>
> const int i=5;
>
> i=10;
>
> that this was an error. But when I compile the code I merely
> get a warning:
>
> warning: assignment of read-only variable `i'
>
> and, worse, it reassigns i to have value 10.
>
> How does one make the compiler elicit a hard error and stop the
> compilation? This is using gcc-3.3.2, by the way.
>
Be aware that when using gcc without additional options you are
compiling to cpp standards even when you have ".c" files.
I don't have a machine handy to check the settings to force it into
ansi c mode. Don't quote me but if memory services its -c99 or -ansi-c.
More information about the PLUG
mailing list