AutosarC++17_03-M7.3.1

The global namespace shall only contain main, namespace declarations and extern “C” declarations

Required inputs: IR

Rationale

Declaring names into appropriate namespaces reduces the names found during lookup, helping to ensure that the names found meet developer expectations.

Exception

The types defined for compliance with Rule 3.9.2 may also be in the global namespace.

Example
void f1 ( int32_t );         // Non-compliant
int32_t x1; // Non-compliant
namespace
{
void f2 ( int32_t ); // Compliant
int32_t x2; // Compliant
} namespace MY_API
{
void b2 ( int32_t ); // Compliant
int32_t x2; // Compliant
}
int32_t main ( ) // Compliant
{
}

Note

For legal reasons, this rule’s description is not part of the public documentation.