Main Content

Group 8: Constants

The custom rules 8.x in Polyspace® enforce naming conventions for constants. For information on how to enable these rules, see Check custom rules (-custom-rules). These rules do not apply to constants that are defined within a class or to constants that are function parameters.

NumberRuleDetails
8.1All global nonstatic constant names must follow the specified pattern.A global nonstatic constant is a constant with external linkage.
8.2All global static constant names must follow the specified pattern.A global static constant is a constant with internal linkage.
8.3All local nonstatic constant names must follow the specified pattern.A local nonstatic constant is a constant without linkage.
8.4All local static constant names must follow the specified pattern.A local static constant is a constant declared static in a function.
8.5All floating constant values must follow the specified pattern.

Say you specify .*F as the pattern. Then this rule checks that the value of each float constant in your code terminates with an F:

float f1 = 10.0F;//Compliant

float f2 = 10.0f; //Noncompliant
This rule does not check the names of the floating constants.