R
Ronald Landheer-Cieslak
I the maintainer fails to realize that a constant is a constant from theDan said:But not the other way round: if the maintainer fails to realise that the
identifier is a constant that could be used in a constant expression,
there is no one to tell him about it.
name of the variable, which, I repeat, should be named for its
functionality, then the variable is probably not named clearly enough.
Failing that, you may have a point
Yeah, that would be a quirk in C.. The following makes your point nicely:In C, there is more than way of defining such constants:
#define MAXVAL 1000 /* MAXVAL can be used in constant expressions */
vs
const int maxval = 1000; /* no maxval in constant expressions */
http://www.embedded.com/story/OEG20011220S0063
IMHO, C++ is right here: a constant expression should accept *any*
constant (i.e. anything of which the value is known at compile-time).
I do not necessarilly concur with all the choices the committee-peopleEven if you don't need them, they certainly help. Have a look at the
constants defined in <limits.h> and <float.h> and see how many of them
aren't all caps.
make - especially where style is concerned.
That said, the first two of the three points you made seem pertinent
enough to concur w/ naming
constants-suitable-for-use-in-constant-expressions in all-caps. That
would go for #defined constants and enums..
Still not convinced for macros, though (even though I usually do name
them in all-caps, BTW ).
rlc