Re: OFFTOPIC: 'do { ... } while (0)?'

tzs@nwnexus.com
Tue, 14 Apr 1998 11:42:20 -0700


>Why are so many macros written as: do { ... } while (0) rather than
>as simply { ... } ?

So as not to break if...else statements. A macro *looks* like a function
call, and so people are going to put a ";" after it. Thus, the macro needs
a good way to eat that ";" that will keep the whole thing as one statement.

--Tim Smith

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu