Topic: Help Preprocessor


Author: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
Date: Sun, 4 Oct 1992 08:57:33 GMT
Raw View
I've got a few minor problems with the specifications for the
preprocessor.

The issue of incomplete /* comments in preprocessor commands is one.

#define fred a + /* incomplete
comment spans lines here */ b

Is the above legal?

The ARM claims

"The source text is decomposed into preprocessing tokens and sequences
of white space. A single white space replaces each comment. A source
file may not end in a partial comment.

[Then, on the next pass]

"Preprocessing directives are executed and macros expanded".

This is a bit tricky. For a start this seems to imply
preprocessor commands can be continued by comments, since
the comments are just replaced by white.

But then it is absurd because if all the newlines were replaced
by white (they are white anyhow) then there would be no way
to delimit the end of the preprocessor command.

Secondly, there might be problems with

#include <filename>

since the < and > are toke. But the filename is implementation dependent.
To fix this, one would have to parse the '#include' tokenising
the rest of the line. (contrary to the ARM requirement).

Any help?


--
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
 Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------




Author: jss@lucid.com (Jerry Schwarz)
Date: Mon, 5 Oct 92 16:13:16 GMT
Raw View
My apologies for the empty article that I just inadvertantly
distributed with this title.

In article <1992Oct4.085733.7703@ucc.su.OZ.AU>, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
|> I've got a few minor problems with the specifications for the
|> preprocessor.
|>
|> The issue of incomplete /* comments in preprocessor commands is one.
|>
|> #define fred a + /* incomplete
|> comment spans lines here */ b
|>
|> Is the above legal?
|>

I belive it is very likely that the final C++ standard will
adapt the  the ANSI/ISO C standard's preprocessing mechanism.
(The main difference is the existence of // comments).  Under
that assumption the above will certainly be legal.  Treatment
of "#include <...>" will also be essentially identical to
that in the C standard.

But at the moment many C++ implementations are built on
non standard preprocessors and their handling of these
issues may not be identical to that of a standard conforming
C compiler.   For maximum portability, don't put comments
into #defines

    -- Jerry Schwarz





Author: jss@lucid.com (Jerry Schwarz)
Date: Mon, 5 Oct 92 16:03:37 GMT
Raw View