Main Content

MISRA C:2023 Rule 20.8

The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1

Since R2024a

Description

Rule Definition

The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1.

Rationale

Strong typing requires that conditional inclusion preprocessing directives, #if or #elif, have a controlling expression that evaluates to a Boolean value.

Troubleshooting

If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.

Check Information

Group: Preprocessing Directives
Category: Required
AGC Category: Advisory

Version History

Introduced in R2024a