Using Macros

Bernard Farrell farrell at onedge.enet.dec.com
Wed Aug 8 02:57:10 AEST 1990


In article <362.26be9dcc at astro.pc.ab.com>, yoke at astro.pc.ab.com (Michael Yoke) writes...

(Some earlier statments removed)

>But, if I define the macro like this
> 
>      #define A_MACRO { stmt1; stmt2; }
> 
>then the semi-colon at the end of the macro reference screws things up.
> 
  When used in

	for (something)
	   A_MACRO;

Michael, the macro expansion would give you:

	for (something)
	{
		stmt1;
		stmt2;
	};

[Indentation is mine for clarity].  The presence of an empty statement after
the closing brace should not cause any problems, though I seem to recall
certain C compilers don't like it being placed here.


Bernard Farrell                | 
  farrell at onedge.enet.dec.com  | Strange but true:
 often on the move so try      |   These thoughts are my own invention,
 home: (617) 332-6203          |   I wish I could blame someone else for
                               |   them !!



More information about the Comp.lang.c mailing list