The global namespace shall only contain main, namespace declarations and extern "C" declarations
The global namespace shall only contain main, namespace declarations and extern "C" declarations.
The rule makes sure that all names found at global scope are part of a namespace. Adhering to this rule avoids name clashes and ensures that developers do not reuse a variable name, resulting in compilation/linking errors, or shadow a variable name, resulting in possibly unexpected issues later.
Other than the main function, the checker flags all names used
at global scope that are not part of a namespace.
The checker does not flag names at global scope if they are declared in
extern "C" blocks (C code included within C++ code). However,
if you use the option -no-extern-c, these names are also flagged.
If you expect a rule violation but do not see it, refer to the documentation for Polyspace® Bug Finder™ or Polyspace Bug Finder Server™.
| Group: Declarations |
| Category: Required |