Thanks to all those who replied. I am very sorry I did not specify the
compiler version etc. I should have. It's gcc version 4.1.3 20070929
(prerelease) (Ubuntu 4.1.2-16ubuntu2).
Glynn Clements wrote:
In C, "const" is only relevant to pointer targets. Adding the "const"
modifier to a variable has no effect.
I don't understand what you mean. I just tried gcc -o foo foo.c on:
# include <stdio.h>
main () {
const int i = 1 ;
i = 2 ;
printf ( "%d\n", i ) ;
}
and I got:
foo.c: In function ‘main’:
foo.c:6: error: assignment of read-only variable ‘i’
So in what sense are you saying adding const to a variable has no effect?
Shriramana Sharma.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html