This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: warning: multi-line comment (why?)


On Mon, Sep 18, 2000 at 12:04:19PM +0200, Jamie Lokier wrote:
> Richard Henderson wrote:
> > > What is the point of this warning?  Shouldn't the preprocessor
> > > just ignore everything between the // and the end-of-line?
> > 
> > No, backslash-newline conversion happens before comments
> > are discarded.  You really do have a multi-line comment;
> > one that would be dangerous if your next line weren't a
> > comment as well.
> 
> But the next line _is_ a comment so the warning is inappropriate here.
>
> If this were a very unlikely situation, fair enough.  But people do
> comment out multi-line macros from time to time using `//', and those
> will trigger the warning.

If you comment out macros during development, you may ignore this warning.
If you need commented macro in release, you have to comment it by /**/.

Multiline comment are dangerous, and even if next line begins with '//', it
is not the right way.

> It can't be too hard to skip whitespace and then check for `//' on the
> next line I'm sure.

I think it can be difficult. Referring to cpplex.c:

/* Skip a C++ line comment.  Handles escaped newlines.  Returns
   non-zero if a multiline comment.  The following new line, if any,
   is left in buffer->read_ahead.  */
static int
skip_line_comment (buffer)
     cpp_buffer *buffer;
{

...
      	return orig_lineno != buffer->lineno;
}

so you'll need lot of readahead and lot of work to get it working right.

Jan Dvorak <johnydog@go.cz>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]