AutosarC++18_10-M16.0.2

Macros shall only be #define’d or #undef’d in the global namespace

Required inputs: IR

Rationale

While it is legal to place #define or #undef directives anywhere in a source file, placing them outside of the global namespace is misleading as their scope is not restricted. This may be inconsistent with developer expectations.

Example
#ifndef MY_HDR 
#define MY_HDR // Compliant
namespace NS
{
#define FOO // Non-compliant
#undef FOO // Non-compliant
}
#endif
See also

Rule 16.0.3

Note

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