Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!cwjcc!tut.cis.ohio-state.edu!osu-cis!att!ihlpl!knudsen From: knudsen@ihlpl.ATT.COM (Knudsen) Newsgroups: comp.lang.c Subject: Re: Calling multiple functions in a macro. Summary: Why use DO? Message-ID: <7462@ihlpl.ATT.COM> Date: 1 Nov 88 19:43:25 GMT References: <353@marob.MASA.COM> Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 23 In article <353@marob.MASA.COM>, daveh@marob.MASA.COM (Dave Hammond) writes: > #define FOO() do { foo1(); foo2(); foo3() foo4(); } while(0) Why use the do and while? C has blocks, you can say just plain {foo1(); ... foo4();} Of course all you're really doing is supplying the braces so the macro can be used "without braces" in the source. I dimly recall defining macros wrapped in {}; they worked fine. > #define FOO() foo1(), foo2(), foo3(), foo4() ( ) This should work as-is, and also yield the value of foo4(). I'd wrap the definition in parentheses, though, as shown. I'd say that in the first example, {} are the sequential equivalent to () in the second, in the sense of keeping you out of trouble in any context. -- Mike Knudsen Bell Labs(AT&T) att!ihlpl!knudsen "Lawyers are like nuclear bombs and PClones. Nobody likes them, but the other guy's got one, so I better get one too."