From: utzoo!decvax!cca!ima!johnl
Newsgroups: net.unix-wizards
Title: Re: Multiple statements in C macros: C s - (nf)
Article-I.D.: ima.277
Posted: Thu Jan  6 03:24:22 1983
Received: Fri Jan  7 01:10:20 1983

#R:vax1:-27300:ima:9200002:000:603
ima!johnl    Jan  5 14:48:00 1983

I thought we went through this a month ago.  If you really want to write
macros that act like statements, you write

# define foo if(1) { any; sequence; of; statments; you; want; } else
				/* Note: NO semicolon after the "else" */

	...
	if(something)
		foo;    /* works as desired */
	else
		foo;    /* also works as desired */

Most C compilers with -O are smart enough to generate good code for this.
In my experience, though, multi-statement defines usually are symptomatic
of premature optimization or else badly designed data structures.

John Levine, decvax!yale-co!jrl, ucbvax!cbosgd!ima!johnl