Eric said:
I'm told that with most optimizing compilers, if you say "const int
foo = 4" rather than "#define foo 4", the compiler won't actually
allocate any memory for the int. True?
It's possible, but not guaranteed. If you take the address of foo, or
declare it in a way that gives it external linkage, the compiler cannot
eliminate it.
And, defying common sense, a "const int" is not a "constant integer
expression" in C, as it would be in C++, so it can't be used in some
places (e.g. a case statement in a switch) that the #define version can.
However, you do get the benefit of additional type checking, so IMHO
it's worth converting as many examples as you can.
S