This is extracted from my module:
When trying to assign a new value to a constant after it's initialization the compiler issues (only) a warning message.
This is not correct in C99 but my module seem to be based on C89 could somebody confirm the validity of this statement as per C89.
C89
and C99
seems to both generate an error
for this case which looks correct, using code in http://ideone.com/x8lXL ;
# C89
[~]> gcc -std=c89 test.c
test.c: In function ‘main’:
test.c:5: error: assignment of read-only variable ‘A’
# C99
[~]> gcc -std=c99 test.c
test.c: In function ‘main’:
test.c:5: error: assignment of read-only variable ‘A’
Also note that clang
agrees to gcc
here.