This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: 'do {} while (0)' replacement
- From: Jens Kilian <jens dot kilian at verigy dot com>
- To: fm3 at os dot inf dot tu-dresden dot de
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 10 Oct 2008 13:49:44 +0200
- Subject: Re: 'do {} while (0)' replacement
- References: <200810091000.45482.fm3@os.inf.tu-dresden.de>
- Reply-to: jens dot kilian at verigy dot com
> On Wednesday 08 October 2008, Richard Harvey Chapman wrote:
> > #define BREAK_ON_ERROR(i) \
> > if (1) \
> > { \
> > if (i < 0) \
> > break; \
> > } \
> > else do \
> > { \
> > } while (0) \
How about
#define BREAK_ON_ERROR(i) if ((i) >= 0) { /* whee! */ } else break
--
mailto:jjk@acm.org phone:+49-7031-4357-122
http://www.bawue.de/~jjk/ fax:+49-7031-4357-483
http://del.icio.us/jjk As the air to a bird, or the sea to a fish,
so is contempt to the contemptible. [Blake]