Empty statements represented by a semicolon ;
are statements that do not perform any operation. They are often the result of a typo or
a misunderstanding of the language syntax. It is a good practice to remove empty statements since they don’t add value and lead to confusion and
errors.
Exceptions
In the case of an empty expanded macro, the issue is not raised.
#define LOG(x)
void fun() {
LOG(X);
}
Code examples
Noncompliant code example
void doSomething() {
; // Noncompliant - was used as a kind of TODO marker
}
#define A(x) x; // Noncompliant - macro definitions should not end with a semi-colon when they are used as functions
void fun() {
A(5); // Noncompliant - after expansion, there are 2 consecutive semi-colons
}
Compliant solution
void doSomething() {
}
#define A(x) x
void fun() {
A(5);
}