no newline at end of file error

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2004
Posts: 56
Reputation: jasweb2002 is an unknown quantity at this point 
Solved Threads: 2
jasweb2002 jasweb2002 is offline Offline
Junior Poster in Training

no newline at end of file error

 
0
  #1
Sep 19th, 2004
Hey everyone,

This is my first time here just to let ya know. Hopefully you can help me.
The language is C++. I am currently working on a file that consists of functions to manipulate doubly linked lists from the main program. After writing several function everything was fine. Then I wrote one function that called a function farther done in the file. This shouldn't give any problems but it did this time. So I cut and pastes the first function so it was after the function it called. This fixed one problem but started a new one. The error was:

80:2 warning: no newline at end of file

The 80 is the always the last line of the file. So if I write more the number changes to 98, 104, 130........ I can't get rid of this error. Even if I delete the functions that "caused" this error. Any idea what I need to do to fix this.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,399
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 247
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: no newline at end of file error

 
0
  #2
Sep 19th, 2004
Go to the last line of the file, to the last character in the line, and hit return/enter.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 256
Reputation: FireNet will become famous soon enough FireNet will become famous soon enough 
Solved Threads: 6
FireNet's Avatar
FireNet FireNet is offline Offline
Posting Whiz in Training

Re: no newline at end of file error

 
0
  #3
Sep 20th, 2004
yea, also you can press Ctrl-End (which take you to the end of the page) and press enter (to make a blank line )

Simple
See what you can, remember what you need

Fourzon | Earn via Coding
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 3
Reputation: micheldup is an unknown quantity at this point 
Solved Threads: 0
micheldup micheldup is offline Offline
Newbie Poster

Re: no newline at end of file error

 
0
  #4
Jun 14th, 2008
Hello,

I have many files that give me that message at compilation.
It would take me too much time to make the suggested modification
in each file.
Is there a compilation option that could remove only this warning message ?

Michel
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: no newline at end of file error

 
0
  #5
Jun 14th, 2008
for i in *.c; do echo >> $i; done
How is that going to take you any time at all to do?

Here I'm assuming that since you're using gcc, that you also have a decent shell to play with as well.

Of course, you could refine it to say
- grep all the lines with that error message
- awk those lines to extract the filenames
- apply the first line to the list of filenames
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 3
Reputation: micheldup is an unknown quantity at this point 
Solved Threads: 0
micheldup micheldup is offline Offline
Newbie Poster

Re: no newline at end of file error

 
0
  #6
Jun 14th, 2008
It works pretty well.
Thanks a lot.

Unfortunately I don't no that much about shell programming.
Is there a way to check first if the modification is needed and
do it only in that case?
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: no newline at end of file error

 
0
  #7
Jun 14th, 2008
Like I said, use 'grep' to find all those error message lines which mention the "no newline" part, then isolate the corresponding filename.

Even passable familiarity with grep / sed / awk / perl and the shell will significantly improve your experience. I suggest you post some example lines, and your attempts at using these tools in the shell scripting forum if you want to continue this further.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 3
Reputation: micheldup is an unknown quantity at this point 
Solved Threads: 0
micheldup micheldup is offline Offline
Newbie Poster

Re: no newline at end of file error

 
0
  #8
Jun 14th, 2008
You are right, I should start studying these subjects!
Thanks a lot
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC