-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Chris Torek wrote:
|>
|>>[const] just isn't the same keyword as in C++, which probably
|>>confuses some people.
|
|
| In article <|
|>It isn't? `const' has largely the same meaning in C and in C++
|>as far as I know. There are some differences in which
|>conversions that change const-ness are allowed implicitly.
|
|
| There are two other semantic differences I would consider
| significant enough to mention:
|
| - C++'s "const" declares actual constants by default, and
| - the default linkage of C++ "const" identifiers is different.
|
| (These two are related, unsurprisingly -- "extern const" in C++
| means what "const" does in C if the variable is not initialized.
| If the variable *is* initialized, though, the C++ "const" is
| still a constant.)
|
| In particular, the following is invalid in C:
Is it still invalid under C99, with VLAs? (I understand that `C'
defaults to C89/C90, but this could possibly confuse someone who
actually had a C99 compiler.)
|
| const int N = 10;
| int a[N];
| int main(void) {
| /* ... code using the array "a" ... */
| return 0;
| }
|
~From what I read of the post you snipped, it seems that Nicloas Pavlidis
should say that `const'-ness in C isn't as strong as it is in C++ or
Pascal or Ada, for example, and that if he wants to avoid /all/
potential surprises arising from the different semantics, he should use
`#define's in C where he would use constant variables in Ada.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird -
http://enigmail.mozdev.org
iD8DBQFBdGd3KxatjOtX+j0RAruSAJ91WVoe4BPg5iQuffAQ5RGyX7uC9wCfQaWo
ftLqRdBJYjOk3NG3XpvXgGM=
=kr6o
-----END PGP SIGNATURE-----