public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Daniel Lohmann <daniel.lohmann@informatik.uni-erlangen.de>
To: Harvey Chapman <hchapman-gcc-help@3gfp.com>
Cc: MSX to GCC <gcc-help@gcc.gnu.org>
Subject: Re: C++ Macros, ##, and ::
Date: Thu, 27 Mar 2008 22:39:00 -0000	[thread overview]
Message-ID: <96F86A13-03E0-48EC-B94E-A306A8242421@informatik.uni-erlangen.de> (raw)
In-Reply-To: <8FC313E8-5249-4F2A-A98E-13927BDDEB76@3gfp.com>


On 27.03.2008, at 21:59, Harvey Chapman wrote:
> Why does ...
>
> #define MT(name) { name::Type, name::Create }
>
> work, and ...
>
> #define MT(name) { name##::Type, name##::Create }
>
> does not?
>
> Is that first one portable? I understand the error I get for the  
> second one about name and :: not constituting a valid pre-processor  
> token, but the first one seems wrong to me. Is :: used in a macro a  
> special case? Or is it an operator? Just looking for some insight to  
> help me remember this.

AFAIK :: is a delimiter to the preprocessor (similar to ,).  Hence,  
the first one should be portable; the latter one does not work as  the  
result of the concatenation has to be a token.

To clarify this in the code , you could even write:

> #define MT(name) { name :: Type, name :: Create }


(Well, just a guess -- I am *never* sure when it comes to the  
preprocessor....)


Daniel

  reply	other threads:[~2008-03-27 22:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-27 21:00 Harvey Chapman
2008-03-27 22:39 ` Daniel Lohmann [this message]
2008-03-30 19:28   ` Nathan Sidwell
2008-03-31 23:38 ` Philipp Thomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=96F86A13-03E0-48EC-B94E-A306A8242421@informatik.uni-erlangen.de \
    --to=daniel.lohmann@informatik.uni-erlangen.de \
    --cc=gcc-help@gcc.gnu.org \
    --cc=hchapman-gcc-help@3gfp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).