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 as
int 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.
_______________________________________________
Help-gplusplus mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gplusplus