[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: traditional cpp
On Mon, Dec 20, 2010 at 12:45:30PM +0000, David Laight wrote:
> > How's it
> > supposed to be done? Right now it's removing comments after macro
> > expansion, but if it removes comments before macro expansion then /**/
> > doesn't work for pasting... or else it has to be treated specially and
> > stripped out again afterwards?
> I think the /*...*/ is treated as a single token.
In Standard C, yes. Traditional cpp doesn't tokenize anything, it just
> Did the original cpp put spaces between output token?
> Passing comments through to the output also requires that // comments
> get converted to /*...*/ ones - otherwise continuation lines cause grief.
Yeah. Well, not exactly, because continuation lines are handled early;
a continuation line inside a // comment continues the comment. The
problem is that if you do
#define A a // blah
#define B b
the output without comments stripped would be
a // blah b
which is at least misleading and possibly totally wrong.
However, really traditional traditional-cpp doesn't handle // comments. :-)
(Arguably it should also reject #if and only accept #ifdef/#ifndef.
But it wouldn't be useful this way.)
David A. Holland
Main Index |
Thread Index |