error: "no newline at end of file"

Zack Weinberg zackw@panix.com
Wed Mar 28 23:38:00 GMT 2007


Gabriel Dos Reis wrote:
> I don't understand your statement.  The C++ (and the C) standard says
>
>  # If a source file that is not empty does not end in a new-line
>  # character, or ends in a new-line character immediately preceded by a
>  # backslash character, the behavior is undefined.
>
> The GNU preprocessor has chosen to diagnose that for ages.

That text as part of the C standard *doesn't* call for a mandatory
diagnostic, though (it is not a violation of a "shall" phrase in a
"constraints" section).  The usual practice in the C front end is to
reserve pedwarn() for mandatory diagnostics that we consider not
worthy of errors.  I don't know about the C++ standard or front end.

In this particular case, I think we should downgrade from
CPP_DL_PEDWARN to CPP_DL_WARNING, because it's not mandatory (at least
in C) and it's a totally harmless thing to do.

zw



More information about the Gcc mailing list