[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ppThrow () flaws

 > This works fine as long as ppThrow is evaluated. But if it's not,
 > ResumeNormalWork () is called even if (correct == false). That's wrong.
 > "ppThrow (..)" has to be replaced by "return errorindicator" in that case.

The if..else cases of most macros tend to be delicate. I use:

#ifdef DEBUG
  #define MyThrow(x,y)  do { printf("failure %ld : %s\n", x, y); } while(0)
  #define MyThrow(x,y)  do { } while(0)

Notice, there is no semicolon.

This is a normal statement that's evaluated once, and lets you declare
temporary variables safely -- even in C. Any compiler worth it's salt
will optimize out the loop. About the only thing you can't do is use
the macro as an r-value.


/* Matt Slot, Bitwise Operator * One box, two box, yellow box, blue box. *
 *  <fprefect@ambrosiasw.com>  * <http://www.ambrosiasw.com/~fprefect/>  */