|
From: | Michael Mair |
Subject: | Re: GCC 3.4.3, silencing "extra semicolon" warnings |
Date: | Wed, 29 Jun 2005 09:27:29 +0200 |
User-agent: | Mozilla Thunderbird 1.0.2 (Windows/20050317) |
Dave Steffen wrote:
Hi Folks, If you turn GCC 3.4's warnings up high enough, you'll get warnings about extra semicolons from such things asint foo() {// ... code in here } ; That semicolon at the end isn't necessary, of course, but I don't think it hurts anything being there. We tend to end up with such things as the result of macro expansion, particularly when using Boost's preprocessor metaprogramming stuff.I like all the other stuff I get with -Wextra -Wall...is there a compiler switch to turn off the "extra `;' " warnings? Alternately, can anyone suggest a legal construct that could be placed between the } and ; (again, say, in a macro definition) to silence the warning?
Note: The superfluous semicolon often brings you in trouble with function-like macros and if--else. The comp.lang.c and comp.lang.c++ faqs both provide a standard way to define function-like macros (different, AFAIR), so I recommend having a look at them. comp.lang.c's faq answer ist #define foo(bar) do { \ /* STUFF ..... */ \ } while (0) Note that the semicolon comes in by the user using the macro like a function: if (qux) foo(baz); else ..... Cheers Michael -- E-Mail: Mine is an /at/ gmx /dot/ de address.
[Prev in Thread] | Current Thread | [Next in Thread] |