Using Macros

Jeff G. Micono jgmicon at sandia.UUCP
Wed Aug 8 06:48:47 AEST 1990


In article <10836 at crdgw1.crd.ge.com>, volpe at underdog.crd.ge.com (Christopher R Volpe) writes:
> Anyway, if the compiler is coughing on it, try the following:
> 
>          #define A_MACRO {stmt1;stmt2;} 0  /* yes, trailing zero */
> 
> Expanding "A_MACRO;" yields the dummy statement "0;" which is ...ds

your solution fails with the following:

if (expr)
  A_MACRO;
else
  printf ("This will not work!\n");


What about

	# define A_MACRO	stmt1,stmt2
	/* no flames, yes I know it's gross, but it works! */


Jeff Micono of Ktech
Ktech Corporation, Albuquerque, NM  87801

"We provide ES&H solutions"



More information about the Comp.lang.c mailing list