This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 'do {} while (0)' replacement


> 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]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]