Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - No newline at end of file warnings: (10 Items)
   
No newline at end of file warnings  
We're trying out the 4.2.1 tools, moving from 2.95.3 and 3.3.5 , using Windows hosted Momentics.

Some large trial projects are compiling fine but every processed source or header file is generating a warning that says
 "warning: no newline at end of file".

The files do seem to be terminated properly and earlier compilers didn't report these warnings.

How do we eliminate these warnings?
Re: No newline at end of file warnings  
ANSI C99 standard says:

5.1.1.2  Translation phases

[...]

         2.  Each instance of a backslash character (\) immediately
             followed by a new-line character is deleted,  splicing
             physical  source  lines  to form logical source lines.
             Only the last backslash on any  physical  source  line
             shall  be eligible for being part of such a splice.  A
             source file that is not empty shall end in a  new-line
             character,  which shall not be immediately preceded by
             a backslash character before any such  splicing  takes
             place.

Sounds like it is a legit warning.

-Adam
amallory@qnx.com
Re: No newline at end of file warnings  
Doesn't the LF entered by the Momentics windows hosted text editor at the end of a line count as a newline? The last 
character in each of these files is LF.
Re: No newline at end of file warnings  
OK, after dumping the problem files in hex it seems the last character is a SPACE, so the end of the file might look 
like this:

}<CR><LF>
<SP>

or in hex

7D 0D 0A 20

Maybe when return was typed on the last line a space was to the right of the cursor, and the space was then placed as 
the last character in the file. If so, that sequence of events would have had to happen in dozens of files here in many 
different projects by several different programmers, all using different editors.

This hardly seems to warrant a warning regardless of what C99 says.
RE: No newline at end of file warnings  
> This hardly seems to warrant a warning regardless of what C99 says.

The standard has the wording 'shall' and that means failure to comply should
elicit a diagnostic message.  As Ryan mentioned, a comprimise would be to
only show the warning when -pendanic is on.

That said, without a NL ending, header files and other includes via
pre-processor might not build properly.  Making the warning disappear
doesn't fix the error and ignoring it is at your own risk.

 -- 
 Cheers,
    Adam

   QNX Software Systems
   [ amallory@qnx.com ]
   ---------------------------------------------------
   With a PC, I always felt limited by the software available.
   On Unix, I am limited only by my knowledge.
       --Peter J. Schoenster 
RE: No newline at end of file warnings  
 

> -----Original Message-----
> From: Adam Mallory [mailto:amallory@qnx.com] 
> Sent: November 4, 2007 9:23 PM
> To: general-toolchain
> Subject: RE: No newline at end of file warnings
> 
> > This hardly seems to warrant a warning regardless of what C99 says.
> 
> The standard has the wording 'shall' and that means failure 
> to comply should elicit a diagnostic message.  As Ryan 
> mentioned, a comprimise would be to only show the warning 
> when -pendanic is on.
> 
> That said, without a NL ending, header files and other 
> includes via pre-processor might not build properly.  Making 
> the warning disappear doesn't fix the error and ignoring it 
> is at your own risk.

Or ours if the issue happens to occur with some system headers.
If this is the case, Ken, please let us know and we'll update
the headers.

Thanks,
 Thomas
Re: RE: No newline at end of file warnings  
We haven't encountered the problem in your headers, only in ours.

The problem seems to occur because the coding style here is that each function is terminated with a brace and a comment,
 something like this:

} // end foo()

In insert mode it's easy to hit enter at the end of the typed comment and if there are spaces to the right they will end
 up at the end of the file.

Where is "dots on" when you need it? :)
Re: RE: No newline at end of file warnings  
Ecliipse has an option to make sure file ends with a newliney, of course that only works when you save them.

It`s under Preferences -> C/C++ -> Editor 
Re: No newline at end of file warnings  
There was an older GNU PR #141331 to add an option to disable this warning message but in May 2007 it was decided that 
the warning message should be removed from the gcc rather than add an option to disable the warning. This change 
happened on the gnu trunk (gcc 4.3), but I see no problem adopting its removal in our gcc 4.2 port. My personal 
preference would have been to keep the warning but only issue it with -pedantic.

Regards,

Ryan Mansfield

Re: No newline at end of file warnings  
Typo -- GCC PR14331.

Regards,

Ryan Mansfield