On 2016-02-01 13:16:20 +0100, Michael Meskes wrote:
> > and ends on an ordinary line. I am not sure what the C standard says
> > about such cases, but I can certainly imagine that some tools might not
> > be very happy with that.
>=20
> We/I have to figure out what the standard says, because if it allows
> these comments, the lexer itself has to be fixed to work correctly
> instead of just fixing the header files.
The relevant translation phases are 3 and 4 according to the C standard
(section 5.1.1.2 in C11):
| 3. The source file is decomposed into preprocessing tokens7) and
| sequences of white-space characters (including comments). A source
| file shall not end in a partial preprocessing token or in a partial
| comment. Each comment is replaced by one space character. New-line
| characters are retained. Whether each nonempty sequence of
| white-space characters other than new-line is retained or replaced
| by one space character is implementation-defined.
|
| 4. Preprocessing directives are executed, macro invocations are
| expanded, and _Pragma unary operator expressions are executed. If a
| character sequence that matches the syntax of a universal character
| name is produced by token concatenation (6.10.3.3), the behavior is
| undefined. A #include preprocessing directive causes the named
| header or source file to be processed from phase 1 through phase 4,
| recursively. All preprocessing directives are then deleted.
Comments are replaced with whitespace in phase 3, preprocessing
directives are are only considered in phase 4. So code like=20
----------------------------------------------------------------------------
#ifndef _ECPGLIB_H /* source created by ecpg which defines thes=
e=E2=90=A4
* symbols */=E2=90=A4
----------------------------------------------------------------------------
is valid C and should be exactly equivalent to
----------------------------------------------------------------------------
#ifndef _ECPGLIB_H =E2=90=A4
=E2=90=A4
----------------------------------------------------------------------------
(=E2=90=A4 denotes a newline character here)
hp
--=20
_ | Peter J. Holzer | I want to forget all about both belts and
|_|_) | | suspenders; instead, I want to buy pants=20
| | | hjp@hjp.at | that actually fit.
__/ | http://www.hjp.at/ | -- http://noncombatant.org/