MISRAC++2008-7-3-1 (C++ only)
In this section:
Synopsis
(Required) The global namespace shall only contain main, namespace declarations and extern C declarations.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
Found a global declaration not being main, namespace or extern C. This check is identical to MISRAC++2023-6.0.3.
Coding standards
- MISRA C++ 2023 6.0.3
(Advisory) The only declarations in the global namespace should be main, namespace declarations and extern "C" declarations
Code examples
The following code example fails the check and will give a warning:
void example(){}
The following code example passes the check and will not give a warning about this issue:
namespace {
void example(){}
}