Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #1873

Re: Preprocessing ##

Path csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end
From George Neuner <gneuner2@comcast.net>
Newsgroups comp.compilers
Subject Re: Preprocessing ##
Date Mon, 15 May 2017 11:31:44 -0400
Organization A noiseless patient Spider
Lines 36
Sender news@iecc.com
Approved comp.compilers@iecc.com
Message-ID <17-05-006@comp.compilers> (permalink)
References <17-05-003@comp.compilers>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 8bit
Injection-Info miucha.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="40555"; mail-complaints-to="abuse@iecc.com"
Keywords C
Posted-Date 15 May 2017 15:23:54 EDT
X-submission-address compilers@iecc.com
X-moderator-address compilers-request@iecc.com
X-FAQ-and-archives http://compilers.iecc.com
Xref csiph.com comp.compilers:1873

Show key headers only | View raw


On Sat, 13 May 2017 08:49:36 +0200, Hans-Peter Diettrich
<DrDiettrich1@netscape.net> 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?
>
>DoDi
>[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.

George

Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Preprocessing ## Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2017-05-13 08:49 +0200
  Re: Preprocessing ## Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2017-05-15 11:28 +0200
  Re: Preprocessing ## Kaz Kylheku <686-678-9105@kylheku.com> - 2017-05-15 13:41 +0000
  Re: Preprocessing ## George Neuner <gneuner2@comcast.net> - 2017-05-15 11:31 -0400
    Re: Preprocessing ## Hans-Peter Diettrich <DrDiettrich1@aol.com.dmarc.email> - 2017-06-02 08:04 +0200

csiph-web