public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "stelek at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug preprocessor/56825] Preprocessor does not expand macro correctly if it is an argument and argument of a macro contains ##
Date: Thu, 04 Apr 2013 06:41:00 -0000	[thread overview]
Message-ID: <bug-56825-4-lRmvtAMq3c@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-56825-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56825

--- Comment #4 from Evgeny Televitckiy <stelek at gmail dot com> 2013-04-04 06:41:38 UTC ---
Ye, I thought it was something along those lines. Thanks for the clarification,
now I understand the reason why this paragraph appear in standard.
Yet, appealing to the end of your comment. I would expect ,##x construct to be
an exception, especially that it has a totally different meaning then
concatenating # or stringifying ##.
Clearly one would expect:
#define E3N(n, ar...) E3NI(_, ##ar, n, n, n)
#define E3NI(a0, a1, a2, a3, ...) a1, a2, a3

#define USE_E3_ARG_R(n, ar...) (E3N(n, ar))
#define USE_E3_ARG_W(n, ar...) (E3N(n, ##ar))

and used:
 USE_E3_ARG_R(5, USE_E3_ARG_R(6, 7));
 USE_E3_ARG_W(5, USE_E3_ARG_W(6, 7));

To produce the same result...

In addition I wanted to add that it is not some virtual problem. I actually
spent 3 hours of my life in that macro hell, trying to understand what went
wrong with that macro,


      parent reply	other threads:[~2013-04-04  6:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-03  9:05 [Bug preprocessor/56825] New: " stelek at gmail dot com
2013-04-03  9:05 ` [Bug preprocessor/56825] " stelek at gmail dot com
2013-04-03  9:09 ` stelek at gmail dot com
2013-04-03 17:31 ` harald at gigawatt dot nl
2013-04-04  6:41 ` stelek at gmail dot com [this message]

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=bug-56825-4-lRmvtAMq3c@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).