Using Macros

Evan Marshall Manning manning at gap.caltech.edu
Wed Aug 8 03:58:55 AEST 1990


farrell at onedge.enet.dec.com (Bernard Farrell) writes:

>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.

I believe the fun variant is:

	if (something)
	    A_MACRO;
	else
	    it_doesn_t_matter;

Try nesting the ifs for more fun!

Gimple Lint will catch this type of errors, as unusual indentation.

-- Evan

***************************************************************************
Your eyes are weary from staring at the CRT for so | Evan M. Manning
long.  You feel sleepy.  Notice how restful it is  |      is
to watch the cursor blink.  Close your eyes.  The  |manning at gap.cco.caltech.edu
opinions stated above are yours.  You cannot       | manning at mars.jpl.nasa.gov
imagine why you ever felt otherwise.               | gleeper at tybalt.caltech.edu



More information about the Comp.lang.c mailing list