...
Adding const
qualification may propagate through a program; as you add const
qualifiers, still more become necessary. This phenomenon is sometimes called "const-poisoning." Const-poisoning can frequently lead to violations of EXP05-A. Do not cast away a const qualification. While const
qualification is a good idea, the costs may outweigh the value in the remediation of existing code.
One may wish to consider using a macroMacros, or an enumeration constant, rather than a const
variable, see may also be used instead of a const
-qualified object. DCL06-A. Use meaningful symbolic constants to represent literal values in program logic for details regarding macros vs. enumeration constants vs. const
variables describes the relative merits of using macros, enumeration constants, and const
-qualified object. However, adding a const
qualifier to a pre-an existing variable is a better first step than replacing the variable with an enumeration constant or macro, because the compiler can then will issue warnings on any code that changes your const
-qualified variable. Once you have verified that a const
-qualified variable indeed is not changed by any code, you may then consider changing it to an enumeration constant or macro, as best fits your design.
...