Macro name is not UPPER_SNAKE_CASE

ID

c.maintainability.naming_macro

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Naming

Language

C / C++

Description

Macro $NAME is not named in UPPER_SNAKE_CASE. By convention, C/C++ preprocessor macros use all-uppercase names with underscores (e.g. MAX_LEN) so they stand out from functions and variables and signal that textual substitution occurs. Rename the macro to match ^[A-Z][A-Z0-9_]*$.

Rationale

Macro $NAME is not named in UPPER_SNAKE_CASE. By convention, C/C++ preprocessor macros use all-uppercase names with underscores (e.g. MAX_LEN) so they stand out from functions and variables and signal that textual substitution occurs. Rename the macro to match ^[A-Z][A-Z0-9_]*$.

The following code illustrates the pattern detected by this rule:

// FLAGGED: Macro name is not UPPER_SNAKE_CASE
#define lower_case 1

Remediation

Follow secure coding practices and review the references below for detailed remediation guidance.

Configuration

This detector does not need any configuration.