Lowercase letter l (ell) can easily be confused with the digit 1 (one). This can be particularly confusing when indicating that an integer literal constant is a long value. This recommendation is similar to DCL02-C. Use visually distinct identifiers. Likewise, you should use uppercase LL rather than lowercase ll when indicating that an integer literal constant is a long long
value.
To be precise when using modifiers to indicate the type of an integer literal, the first character may not be l
. It may be L
, u
, or U
. Subsequent characters have no strict case requirements.
Noncompliant Code Example
...
Tool | Version | Checker | Description | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Astrée |
| long-suffix | Fully checked | |||||||||||||
Axivion Bauhaus Suite |
| CertC-DCL16 | ||||||||||||||
CodeSonar |
| LANG.TYPE.CSUF | Confusing literal suffix | |||||||||||||
| CC2.DCL16 | Fully implemented | ||||||||||||||
Helix QAC |
| C1280 | ||||||||||||||
LDRA tool suite |
| 252 S | Fully implemented | |||||||||||||
Parasoft C/C++test |
| CERT_C-DCL16-aUse capital 'L' instead of lowercase 'l' to indicate long | The lowercase form of 'L' shall not be used as the first character in a literal suffix | |||||||||||||
PC-lint Plus |
| 620 | Fully supported | |||||||||||||
Polyspace Bug Finder |
| MISRA CERT C: 2012 Rule 7.3 | The lowercase character “l” shall not be used in a literal suffix | PRQA QA-C | ||||||||||||
Include Page | PRQA QA-C_v | PRQA QA-C_v | 1280 | Rec. DCL16-C | Checks for use of lowercase "l" in literal suffix (rec. fully covered)Fully implemented | |||||||||||
RuleChecker |
| long-suffix | Fully checked | |||||||||||||
SonarQube C/C++ Plugin |
| LiteralSuffix |
...