Re: Preprocessing ##

George Neuner <>
Mon, 15 May 2017 11:31:44 -0400

          From comp.compilers

Related articles
Preprocessing ## (Hans-Peter Diettrich) (2017-05-13)
Re: Preprocessing ## (Hans-Peter Diettrich) (2017-05-15)
Re: Preprocessing ## (Kaz Kylheku) (2017-05-15)
Re: Preprocessing ## (George Neuner) (2017-05-15)
| List of all articles for this month |

From: George Neuner <>
Newsgroups: comp.compilers
Date: Mon, 15 May 2017 11:31:44 -0400
Organization: A noiseless patient Spider
References: 17-05-003
Injection-Info:; posting-host=""; logging-data="40555"; mail-complaints-to=""
Keywords: C
Posted-Date: 15 May 2017 15:23:54 EDT

On Sat, 13 May 2017 08:49:36 +0200, Hans-Peter Diettrich
<> wrote:

>How is the C preprocessor assumed to handle the ## concatenation operator?

It concatenate tokens *prior* to expansion. If the token references a
parameter of the current macro, the (text of the) parameter is
substituted, otherwise the token is simply copied.

e.g, #define foo(x) one ## two
          ... foo(help) => onetwo

          #define foo(x) x ## _me
          ... foo(help) => help_me

>In the Windows headers I found macros like
> #define foo(x) bar(##baz(x))
>where an expansion into ... (baz ... doesn't make sense, because "(baz"
>is not a valid preprocessor token. Can somebody explain the meaning and
>handling of such constructs?
>[I would guess that some macro between ( and ## expanded to
>nothing. Or it could just be one of those text editing errors. -John]

I think John probably is correct that you've found typos. If it were
the result of a macro substitution, you would see it only in the
output of the preprocessor - it would not be visible in an input
header file.

Moreover, although I'm not 100% certain, I believe the preprocessor
does not substitute inside (it's own) preprocessor definitions, but
rather only substitutes into C code.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.