By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,513 Members | 1,611 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,513 IT Pros & Developers. It's quick & easy.

Whats this Error mean?

P: n/a
This occured right after i tryed to compile the file
hello.cpp:9:2: warning: no newline at end of file

Nov 9 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Weasel wrote:
This occured right after i tryed to compile the file
hello.cpp:9:2: warning: no newline at end of file


Uhhmmm... it means what it says. The last character of the file is
supposed to be a newline. Open the file. Go to the end. Hit <Enter>
(or whatever the equivalent is on your keyboard). Save the file.
Recompile. The warning should be gone.

By the way - it was a warning, not an error. It didn't stop you from
compiling the file, but making the above change will make the compiler
stop giving you that warning. But you should consult your compiler
documentation for more info.

Best regards,

Tom

Nov 9 '05 #2

P: n/a
o ok ty ty ty sorry im just learning c++ :(

Nov 9 '05 #3

P: n/a
Weasel wrote:
o ok ty ty ty sorry im just learning c++ :(


That's nice. Are you still learning how to use Google? I know I've
mentioned the quote thing to you before? Why are you not using it?
Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Nov 9 '05 #4

P: n/a
In article <11**********************@g44g2000cwa.googlegroups .com>,
Weasel <We********@gmail.com> wrote:
This occured right after i tryed to compile the file
hello.cpp:9:2: warning: no newline at end of file


Comeau, in strict mode, gives:

error: last line of file ends without a newline

In other modes it might just be a warning.
In C mode, the diagnostic can be removed.
As both these compilers are saying, source files should
end with a newline. The C++ Standard says in 2.1p2:
"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."
C99 5.1.1.2p2 reads:
"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."

This normally occurs as a result of a text editor that does not
put out a trailing NL in a text file. It may also indicate that
somehow the rest of a file got tossed, though that would also
normally give some other errors if it got cut off so abruptly.
--
Greg Comeau / Celebrating 20 years of Comeauity!
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Nov 11 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.