[PLUG] C question on "const int"

Dean S. Messing deanm at sharplabs.com
Fri May 13 19:34:29 UTC 2005




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.

Dean




More information about the PLUG mailing list