[net.lang.c] ANSI C Question

herndon@umn-cs.UUCP (03/08/85)

  If the ANSI standard allows spaces between the name of macro and
the parenthesis introducing the parameter list, how is the pre-processor
supposed to disinguish between:

#define NULLMACRO (x, y, z)  /* 3 param macro expands to nothing at all */

and 

#define XYZMACRO (x, y, z)   /* 0 param macro expands to "(x, y, z)" */

Maybe quote interpretation rules will come into play, but these don't
exist now, and will probably break many existing programs.  What does
the standard claim, or has it ignored this?  This "no spaces between
macro name and parenthesis introducing parameter list" restriction also
occurs in the 'm4' macro processor, I suspect for good reason.


					Robert Herndon
					...!ihnp4!umn-cs!herndon

kdmoen@watcgl.UUCP (Doug Moen) (03/13/85)

In response to Robert Herndon's question,
the draft Ansi C standard has this to say about macros and parameter lists:
	#define foo (x, y, z)	/* define macro with no parameters */
	#define bar(x, y, z)	/* define macro with 3 parameters */
		bar(a, b, c)	/* use bar */
		bar (a, b, c)	/* another way to use bar */

In other words, you can put spaces between the macro name and its
actual parameter list (when you use it), but not between the name and
the formal parameter list (when you define it).

The question probably arose because my original posting wasn't very clear:
> There may be white space between a macro name and the ( )'s enclosing
> its actual parameter list (Unix cpp disallows this).

Doug Moen, watmath!watcgl!kdmoen
University of Waterloo Computer Graphics Lab

jim@ISM780B.UUCP (03/17/85)

> There may be white space between a macro name and the ( )'s enclosing
> its actual parameter list (Unix cpp disallows this).

I don't understand this comment.  Reiser cpp allows arbitrary
white space between the macro name and the parenthesis
introducing its actual (use, not definition) argument list.

-- Jim Balter, INTERACTIVE Systems (ima!jim)