This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Empty statement warning!
- From: Agnar Renolen <agnar dot renolen at emap dot no>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 25 Nov 2011 13:25:48 +0100
- Subject: Empty statement warning!
I'm sometimes doing the obvious mistake of adding a ";" after an if-statement.
if (<expression>);
DoSomething();
This error sometimes causes weird behaviour of the program, and are hard to spot in the code.
I once read a recommendation that you should always add curly braces, even if for single statement blocks:
if (<expression>);
{
DoSomething();
}
...as this would normally cause a good compiler to issue a warning.
But, using XCode on Mac (built on top of GCC) I'm not warned for these errors, and I can't find an option in Xcode to enable such a warning.
Is there another way to make gcc issue a warning for empty statements such as the one above (I know it's legal C / C++ code, but it's use is fairly narrow I would say).
Agnar
--
Agnar Renolen
eMap as (www.emap.no)