Topic: macro to define //
Author: jimad@microsoft.com (Jim Adcock)
Date: Wed, 10 Nov 1993 19:06:50 GMT Raw View
In article <rfgCG03Mo.Mwx@netcom.com> rfg@netcom.com (Ronald F. Guilmette) writes:
>In ANSI/ISO C, comments are "replaced by one space character" very early,
>i.e. in translation phase 3, so Paul's trick would not work in ANSI/ISO C
>(for C-style comments) but in C++... well...
...well, ARM 16.1 also calls out that the 3rd phase includes removal
of comments, whereas macro expansion doesn't occur till phase four.
Thus a "//" resulting from macro expansion should be interpreted
not as a comment, but as two div signs -- IE a syntax error.
[Subject to "reinterpretation" by the committee, of course.]
Some compilers [erroneously] include two distinct phases of comment removal,
presumably as a balm to some pre-C++ C preprocessors which don't 'correctly'
strip the '//' comments.
Author: jamshid@ses.com (Jamshid Afshar)
Date: Sat, 13 Nov 1993 00:33:33 GMT Raw View
In article <rfgCG03Mo.Mwx@netcom.com>,
Ronald F. Guilmette <rfg@netcom.com> wrote:
>In article <CFJ324.FBs@cbnewse.cb.att.com> grumpy@cbnewse.cb.att.com (Paul J Lucas) writes:
>> Absurdity aside, try: #define COMMENT name2(/,/)
>> although I think John Skaller will yell at me again for this.
>In ANSI/ISO C, comments are "replaced by one space character" very early,
>i.e. in translation phase 3, so Paul's trick would not work in ANSI/ISO C
>(for C-style comments) but in C++... well... the standardization committee
>hasn't even looked at incorporation of translation phases yet, so who the
>hell knows. (I sure don't.)
Is there really any doubt about this? Am I missing something or did
you not notice WP 2.1 "Phases of Preprocessing"?
Btw, this isn't all new in the WP. The ARM discusses phases of
preprocessing in 16.1. Apparently ANSI/ISO split ARM 16
"Preprocessing" into WP sections 2.1 through 2.8 and 16 "Preprocessing
Directives". WP adds digraphs.
Jamshid Afshar
jamshid@ses.com
Author: rfg@netcom.com (Ronald F. Guilmette)
Date: Mon, 15 Nov 1993 09:01:25 GMT Raw View
In article <CGEMvy.8rx@ses.com> jamshid@ses.com (Jamshid Afshar) writes:
>In article <rfgCG03Mo.Mwx@netcom.com>,
>Ronald F. Guilmette <rfg@netcom.com> wrote:
>>In article <CFJ324.FBs@cbnewse.cb.att.com> grumpy@cbnewse.cb.att.com (Paul J Lucas) writes:
>>> Absurdity aside, try: #define COMMENT name2(/,/)
>>> although I think John Skaller will yell at me again for this.
>>In ANSI/ISO C, comments are "replaced by one space character" very early,
>>i.e. in translation phase 3, so Paul's trick would not work in ANSI/ISO C
>>(for C-style comments) but in C++... well... the standardization committee
>>hasn't even looked at incorporation of translation phases yet, so who the
>>hell knows. (I sure don't.)
>
>Is there really any doubt about this? Am I missing something or did
>you not notice WP 2.1 "Phases of Preprocessing"?
I stand corrected (again).
--
-- Ronald F. Guilmette, Sunnyvale, California -------------------------------
------ domain address: rfg@netcom.com ---------------------------------------
------ uucp address: ...!uunet!netcom.com!rfg -------------------------------
Author: rfg@netcom.com (Ronald F. Guilmette)
Date: Fri, 5 Nov 1993 04:11:11 GMT Raw View
In article <CFJ324.FBs@cbnewse.cb.att.com> grumpy@cbnewse.cb.att.com (Paul J Lucas) writes:
>From article <1993Oct26.220230.24172@asl.dl.nec.com>, by jng@aslslc71.asl.dl.nec.com (James Ng):
>>
>> I would like to define a macro for the C++ comment symbol.
>> i.e. #define COMMENT //
>> But our C++ compiler ( 3.0 Cfront compliant ) will not accept
>> since // is already is already the comment symbol. Therefore
>> // is being ignored.
>>
>> I wonder if this is possible or I may have to try another approach
>> to solve my real problem. ( instead of trying to #define // )
>
> *WHY*?
>
> Absurdity aside, try: #define COMMENT name2(/,/)
> although I think John Skaller will yell at me again for this.
>--
> - Paul J. Lucas
> AT&T Bell Laboratories
> Naperville, IL
In ANSI/ISO C, comments are "replaced by one space character" very early,
i.e. in translation phase 3, so Paul's trick would not work in ANSI/ISO C
(for C-style comments) but in C++... well... the standardization committee
hasn't even looked at incorporation of translation phases yet, so who the
hell knows. (I sure don't.)
(Follow-ups to comp.std.c++ please.)
--
-- Ronald F. Guilmette, Sunnyvale, California -------------------------------
------ domain address: rfg@netcom.com ---------------------------------------
------ uucp address: ...!uunet!netcom.com!rfg -------------------------------