Reputation: 2464
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.
Upvotes: 0
Views: 225
Reputation: 47602
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.
Upvotes: 2
Reputation: 4585
I just checked the major differences in C99 from C89 and there is nothing mentioned about changes in 'const' keyword.
[off-topic] However, I am not getting the whole C89 standard drafts. Any one know from where I can download it?
Upvotes: 0