Constant name is not UPPER_SNAKE_CASE
ID |
c.maintainability.naming_constant |
Severity |
info |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Naming |
Language |
C / C++ |
Description
Constant $N is not named in UPPER_SNAKE_CASE. By convention, C/C++ named constants (both const objects and object-like macros) use all-uppercase names with underscores (e.g. MAX_LEN) so they are easy to spot as compile-time values. Rename it to match ^[A-Z][A-Z0-9_]*$.
Rationale
Constant $N is not named in UPPER_SNAKE_CASE. By convention, C/C++ named constants (both const objects and object-like macros) use all-uppercase names with underscores (e.g. MAX_LEN) so they are easy to spot as compile-time values. Rename it to match ^[A-Z][A-Z0-9_]*$.
The following code illustrates the pattern detected by this rule:
// FLAGGED: Constant name is not UPPER_SNAKE_CASE
#define buffer_size 256