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

do ... while(0) in macros



Well, I don't profess to know definite RTEMS-specific answers, but as was
pointed out in one of my classes, a do-while loop always executes at least
once, even if the condition if false. It executes before evaluation.

On the other hand, I won't comment on the form, but I do know that it is
entirely possible in C to redefine 0, potentially producing a loop here
that executes multiple times.

DanL

On Wed, 8 Aug 2001, CARERI/SED wrote:

> There are many macros in RTEMS written like the following code:
>
>   do {
>   } while (0)
>
> Could anybody explain the purpose of the "do ... while(0)" ?