Possible Duplicate:
“No newline at end of file” compiler warning
i am a Linux user and use gcc at work But at home i have installed cygwin package and using its gcc
on my windows machine.
when ever i make any .c file and run its shows following warning
Warning : No new line at end of file
when i add extra new line at the end of that c file warning disappeared. i haven't faced such warning while working with gcc in Linux.
so
why i am getting this warning? what does it mean ?
Edit
Whats the need or whats the advantage of doing this ?
if it is part of c programming standard then why it doesnt give any error while working in linux ?
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.
It indicates that you do not have a newline (usually '\n' , aka CR or CRLF) at the end of file. That is, simply speaking, the last byte (or bytes if you're on Windows) in the file is not a newline.
If content is added to the end of the file, then the line that was previously the last line will have been edited to include a newline character. This means that blame ing the file to find out when that line was last edited will show the text addition, not the commit before that you actually wanted to see.
So, it turns out that, according to POSIX, every text file (including Ruby and JavaScript source files) should end with a \n , or “newline” (not “a new line”) character. This acts as the eol , or the “end of line” character. It is a line “terminator”.
The C language requires that every source file must end with a newline (from C99 5.1.1.2/1):
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.
(C++ also had this requirement prior to C++11)
No newline at end of file shows why you are getting this error and why it may be bad not to have a newline.
You are probably not getting this at work because whatever editor you use at work is probably adding newlines at the ends of text lines and the editor you're using at home isn't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With