"Empty statement" warnings for disabled macros

I have the usual sort of DEBUG macros:

#define serial_debug(...) Serial.debug(__VA_ARGS__)
#define serial_debug(...)

In the code, if SERIAL_DEBUG is not defined, then this line is identified with the warning "Empty statement":

serial_debug("Hello world!");

I think this is because there is essentially a semicolon without a preceding statement.
How can the warning be removed without disabling the inspection?

I could add a semicolon to the macro definition and remove it from each use of the macro, but seeing statements in the code without semicolons looks wrong.


1 comment

You can define a c++ NOP statement like this

#define serial_debug(...) void()

for the non-debug case. The compiler sees a statement, thus doesn't complain, and compiles it to nothing.


Please sign in to leave a comment.