public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Zack Weinberg <zack@codesourcery.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: c++/8297: problem with preprocessor Date: Sun, 20 Oct 2002 23:46:00 -0000 [thread overview] Message-ID: <20021021064601.9552.qmail@sources.redhat.com> (raw) The following reply was made to PR c++/8297; it has been noted by GNATS. From: Zack Weinberg <zack@codesourcery.com> To: riteshg@pune.tcs.co.in Cc: gcc-gnats@gcc.gnu.org Subject: Re: c++/8297: problem with preprocessor Date: Sun, 20 Oct 2002 23:42:52 -0700 On Mon, Oct 21, 2002 at 05:46:30AM -0000, riteshg@pune.tcs.co.in wrote: > when i run > > #define comment /##/ > comment > > the output is coming as space between twp front slash "/ /". > and it is supposed to come "//" . I am using gcc 3.0 . Till > older versions than gcc3.0 it is comming correctly as "//" . > And also in older version preprocessor is not processing the user > defined comments as > > #define comment /##/ > comment > > when ran with -E option gives output in preprocessed file > as > // I'm sorry, but you have it backward. The 2.x preprocessor was buggy; the behavior of the 3.0 and later preprocessor is correct. // is not a preprocessing token. If it appears in source text, it introduces a line comment, which is stripped from the program _before_ the text is broken into tokens. Otherwise, it is simply two "/" tokens adjacent to each other. You attempted to force the creation of a single token "//" with the ## operator. This induces undefined behavior: GCC can do whatever it likes. We choose to have it issue a warning and pretend there was no ## operator; thus, two "/" tokens are passed to the output routines. They then have to insert a space, so that these two "/" tokens are not later misinterpreted as introducing a line comment. If you describe what you are actually trying to do, we may be able to offer advice on how to do it properly. zw
next reply other threads:[~2002-10-21 6:46 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-10-20 23:46 Zack Weinberg [this message] -- strict thread matches above, loose matches on Subject: below -- 2002-10-21 12:56 Neil Booth 2002-10-21 0:16 Ritesh Goel 2002-10-20 23:44 zack 2002-10-20 22:56 riteshg
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=20021021064601.9552.qmail@sources.redhat.com \ --to=zack@codesourcery.com \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@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: linkBe 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).