PDA

View Full Version : Warning, no newline at end of file; why?



M$LOL
April 7th, 2007, 07:38 PM
Why does GCC warn about not having a newline at the end of the file? What difference would it make to the compiled program? :-k

treak007
April 7th, 2007, 08:09 PM
its part of the language standard:

"A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character."

Fhernd
June 19th, 2008, 03:54 PM
Hi!


That's not an error. It's just a warning.

Open the file in an editor, go to the last line of the file, and hit enter to add a blank line to the end of the file. :)

Though, besides that, you should be using #include <iostream> instead of <iostream.h>. Then put in a "using std::cout;" after it.


So long!

KingTermite
June 19th, 2008, 04:25 PM
Did it warn you that there was no newline at the end of the file, or did it say something like "reached the end of file and no EOF character found" (or something like that?).

I ask because the 2nd one is an error I've seen in Visual Studio many times when you have mismatched (usually missing) braces.

xlinuks
June 19th, 2008, 04:31 PM
its part of the language standard:

"A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character."

This is something I would really want C/C++ to get rid of. It has nothing to do with "real programming" but rather with "bureaucracy", I've been programming for years in other languages and did fine without this annoying issue.

LaRoza
June 19th, 2008, 05:53 PM
This is something I would really want C/C++ to get rid of. It has nothing to do with "real programming" but rather with "bureaucracy", I've been programming for years in other languages and did fine without this annoying issue.

Tell the working group: ISO/IEC JTC1/SC22/WG14.

(Now you know why it is "bureaucracy", a committee made it)

xlinuks
June 19th, 2008, 06:16 PM
The ISO is lately no more a "committee" for me and a lot of other persons, but a bunch of losers, after what they did with ooxml.

RIchard James13
June 20th, 2008, 08:24 AM
Yes the standard is stupid but we should either ignore the warning or alter our files. I alter my files, if I want the standard to be changed I will also want to win lotto. I know which one will happen sooner :)

evymetal
June 20th, 2008, 08:35 AM
I disagree (slightly) - It's always a good idea to end files in a newline, especially in Unix (for back compatibility reasons).

e.g. when running a shell script or something that requires a newline to tell the program to run that line

kutlu
January 16th, 2010, 10:39 PM
when this file is included somewhere, it will be problem.

it replaces itself with include statement, and a replacement without a new line is sometimes problematic.

Once, I had a tough day since visual studio does not give this warning, and an unsolvable error instead.

so, put the new line there! I am serious.