[comp.std.c] A question about the pp-tokens in macro actual arguments.

rfg@lupine.ncd.com (Ron Guilmette) (03/12/91)

OK boys and girls.  It's stump-the-stars time again.

This one should be easy.

When a formal argument for a function-like macro is replaced (whilst a
macro call is being expanded) must (or may) the sequence of replacement
pp-tokens include leading and/or trailing whitespace if the corresponding
actual argument also contained leading or trailing whitespace (respectively)?

In other words, what should be the result of:

	#define PREFIX(x) prefix##x

	... PREFIX ( xxyyzz) ...

diamond@jit345.swstokyo.dec.com (Norman Diamond) (03/13/91)

In article <4370@lupine.NCD.COM> rfg@lupine.ncd.com (Ron Guilmette) writes:

>This one should be easy.

These two are easy.

>When a formal argument for a function-like macro is replaced (whilst a
>macro call is being expanded) must (or may) the sequence of replacement
>pp-tokens include leading and/or trailing whitespace if the corresponding
>actual argument also contained leading or trailing whitespace (respectively)?

Whitespace is not part of a token.  However, whitespace may separate tokens.
If the preprocessor puts some whitespace (back) in when replacing an
argument, it should not matter.

And now for something completely different:

>In other words, what should be the result of:
>	#define PREFIX(x) prefix##x
>	... PREFIX ( xxyyzz) ...

The tokens must be pasted.
... [possible whitespace] prefixxxyyzz [possible whitespace] ...

--
Norman Diamond       diamond@tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.