From: utzoo!decvax!duke!unc!tim
Newsgroups: net.lang.c
Title: Multiple-statement macros
Article-I.D.: unc.4482
Posted: Sun Jan  9 21:35:13 1983
Received: Mon Jan 10 02:05:25 1983


     This controversy seems to have gotten revived on  unix-
wizards.   No  one  has  mentioned what seems to me the most
important aspect of  all  these  examples:  doing  something
like:

    #define groucho { a++; b = c * d; }

    if (cond) groucho else a--;

is terrible style. If a macro does something, make  it  look
like  a  function  call, even if it doesn't have any parame-
ters.  Parameterless macros should be used only for defining
symbolic  constants.   C  can be hard enough to read without
abusing the preprocessor.

     In any case, all multiple statement macros  should  use
the , (comma) operator.  This will only fail if you use con-
trol structures, which is bad practice in  a  macro  anyway.
(There is always ?: if you need a condition.) This makes the
whole thing one statement, eliminating any problem.

					Tim Maroney
					unc!tim