'do {} while (0)' replacement
Frank Mehnert
fm3@os.inf.tu-dresden.de
Wed Oct 8 19:24:00 GMT 2008
Hi,
I'm searching for a replacement of
do {} while (0)
in a macro definition.
My problem is the following:
#define BREAK_ON_ERROR(i) \
if (1) \
{ \
if (i < 0) \
break; \
} \
else do \
{ \
} while (0) \
int foo(void)
{
for (;;)
{
int bar = 1, buzz = 2;
if (bar)
BREAK_ON_ERROR(buzz);
}
}
gcc-4.3 will warn with
'warning: suggest explicit braces to avoid ambiguous `else'
Any hints for a clever replacement of 'do {} while (0)' in this
case? Of course, enclosing the BREAK_ON_ERROR statement like
if (bar)
{
BREAK_ON_ERROR(buzz)
}
is possible but not what I want :-)
Thanks in advance,
Frank
--
## Dept. of Computer Science, Dresden University of Technology, Germany ##
## http://os.inf.tu-dresden.de/~fm3 ##
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20081008/ee52de7a/attachment.sig>
More information about the Gcc-help
mailing list