CERT-DCL04-C
In this section:
Synopsis
Do not declare more than one variable per declaration.
Enabled by default
Yes
Severity/Certainty
Low/High

Full description
Multiple variables in a single declaration may cause a developer to misinterpret code when it comes to the type of such variables This check is identical to MISRAC++2008-8-0-1, MISRAC++2023-10.0.1.
Coding standards
- MISRA C++ 2008 8-0-1
(Required) An init-declarator-list or a member-declarator-list shall consist of a single init-declarator or member-declarator respectively.
- MISRA C++ 2023 10.0.1
(Advisory) A declaration should not declare more than one variable or member variable
Code examples
The following code example fails the check and will give a warning:
int example() {
int a,b,c;
}
The following code example passes the check and will not give a warning about this issue:
int example() {
int a; int b; int c;
}