AutosarC++17_03-M16.0.7¶
Undefined macro identifiers shall not be used in #if or #elif preprocessor directives, except as operands to the defined operator
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
If an attempt is made to use an identifier in a preprocessor directive, and that identifier has not been defined, the preprocessor will assume the value zero. #ifdef, #ifndef and defined() are provided to test the existence of a macro, and are therefore excluded.
Example
#if x < 0 // Non-compliant - x assumed to be zero as it is not defined
Consideration should be given to the use of a #ifdef test before an identifier is used.
Note that preprocessing identifiers may be defined either by use of #define directives or by options specified at compiler invocation. However, the use of the #define directive is preferred.
Note
For legal reasons, this rule’s description is not part of the public documentation.