Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > warning : no new line at end of file

Reply
Thread Tools

warning : no new line at end of file

 
 
Sameer
Guest
Posts: n/a
 
      12-29-2005
Hi,
when i compile my C programs (even 2 line progs) give the warning, no
new line at end of file.
What does this mean ?
-Regards,
Sameer

 
Reply With Quote
 
 
 
 
Rahul Chandok
Guest
Posts: n/a
 
      12-29-2005
Hi,

Can you please type the program you are trying to compile.

It would be helpful for us if you tell us the compilation environment.
for e.g. OS used and compiler version used.

Rahul

 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      12-29-2005
"Sameer" <> writes:
> when i compile my C programs (even 2 line progs) give the warning, no
> new line at end of file.
> What does this mean ?


It means there's no newline at the end of the file. What do you think
it means?

In your text editor, add a newline to the end of the file you're
trying to compile. (Some editors do this automatically; yours
apparently doesn't.)

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
Chuck F.
Guest
Posts: n/a
 
      12-29-2005
Sameer wrote:
>
> Hi, when i compile my C programs (even 2 line progs) give the
> warning, no new line at end of file. What does this mean ?


It means that there was no newline character at the end of the
source file. You must be failing to hit <ret> (or <enter>) after
typing the last source line in your editor.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
 
Reply With Quote
 
Richard Bos
Guest
Posts: n/a
 
      12-29-2005
"Sameer" <> wrote:

> when i compile my C programs (even 2 line progs) give the warning, no
> new line at end of file.


It means, surprise, surprise, that there is no new-line at the end of
your source file. Quoth the Standard:

# A source file that is not empty shall end in a new-line character

Richard
 
Reply With Quote
 
Sameer
Guest
Posts: n/a
 
      12-29-2005
this is the source code :

#include <stdio.h>

main()
{
printf("hi\n") ;

}
when i compile it i get
warning: no new line at end of file
I am using madrake linux and compiling it with gcc

 
Reply With Quote
 
Sameer
Guest
Posts: n/a
 
      12-29-2005
thanks a lot. now it is working fine.

 
Reply With Quote
 
John Smith
Guest
Posts: n/a
 
      12-29-2005
> It means, surprise, surprise, that there is no new-line at the end of
> your source file. Quoth the Standard:
>
> # A source file that is not empty shall end in a new-line character


So the next obvious question is to ask why it is this way?

I personally think it's one of the most dumb restrictions ever made. Does it
change anything about how the program is compiled? No! I mean, who cares
about blank lines. It's the code which is important.

Apple also seems to have disabled this in their version of gcc on Mac OS X.

-- John


 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      12-29-2005
[Followups set to comp.lang.c]

John Smith said:

>> It means, surprise, surprise, that there is no new-line at the end of
>> your source file. Quoth the Standard:
>>
>> # A source file that is not empty shall end in a new-line character

>
> So the next obvious question is to ask why it is this way?


Presumably because a source file is intended to be a text file, and a text
file comprises zero or more lines, and a line comprises zero or more
characters terminated by a newline character.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
 
Reply With Quote
 
Richard Bos
Guest
Posts: n/a
 
      12-29-2005
"John Smith" <> wrote:

> > It means, surprise, surprise, that there is no new-line at the end of
> > your source file. Quoth the Standard:
> >
> > # A source file that is not empty shall end in a new-line character

>
> So the next obvious question is to ask why it is this way?


Because there are OSes where a text file is stranger even than the
mindset of a Unix-head.

> I personally think it's one of the most dumb restrictions ever made. Does it
> change anything about how the program is compiled? No! I mean, who cares
> about blank lines.


The restriction is not on blank lines; the restriction is that the final
line, like all the others, must be properly terminated.

Not all the world is a toy OS from Berzerkeley, you know.

Richard
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read a file line by line and write each line to a file based on the5th byte scad C++ 23 05-17-2009 06:11 PM
Re: illegal line end in character literal in escaped unicode CARRIAGERETURN / NEW LINE Joshua Cranmer Java 0 05-15-2009 02:50 PM
Re: illegal line end in character literal in escaped unicode CARRIAGERETURN / NEW LINE Lew Java 0 05-15-2009 02:38 PM
Re: illegal line end in character literal in escaped unicode CARRIAGERETURN / NEW LINE Mark Space Java 0 05-15-2009 02:35 PM
Re: illegal line end in character literal in escaped unicode CARRIAGE RETURN / NEW LINE Andreas Leitgeb Java 0 05-15-2009 02:02 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57