[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RP] [PATCH] silence warnings
From: |
Andre Noll |
Subject: |
Re: [RP] [PATCH] silence warnings |
Date: |
Tue, 28 Apr 2009 13:04:39 +0200 |
User-agent: |
Mutt/1.5.9i |
On 11:38, Bernhard R. Link wrote:
> * empty if or else branches
> as PRINT_DEBUG is sometimes empty, gcc warns about empty if and else
> braches. With some { } that stops (though other compilers might warn
> more). But I think this way it is "safest" to have no ugly effects
> (not that the danger was more than insignificant before)...
One common approach to deal with macros that might expand to nothing
is using constructs like
#define PRINT_DEBUG(foo) do { ... } while (0)
This avoids all warnings and works for all compilers. More importantly,
it catches the following class of bugs:
if (foo)
PRINT_DEBUG(...)
statement;
If PRINT_DEBUG(...) expands to nothing, the compiler will _not_
complain about the missing semicolon, and the code does _not_ do what
is suggested by the indentation.
Just my 2 cent.
Andre
--
The only person who always got his work done by Friday was Robinson Crusoe
signature.asc
Description: Digital signature