944,004 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 19770
  • C++ RSS
Sep 19th, 2004
0

no newline at end of file error

Expand Post »
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.
Similar Threads
Reputation Points: 11
Solved Threads: 2
Junior Poster in Training
jasweb2002 is offline Offline
56 posts
since Sep 2004
Sep 19th, 2004
0

Re: no newline at end of file error

Go to the last line of the file, to the last character in the line, and hit return/enter.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Sep 20th, 2004
0

Re: no newline at end of file error

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
Reputation Points: 108
Solved Threads: 7
Posting Whiz in Training
FireNet is offline Offline
256 posts
since May 2004
Jun 14th, 2008
0

Re: no newline at end of file error

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
micheldup is offline Offline
3 posts
since Jun 2008
Jun 14th, 2008
0

Re: no newline at end of file error

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
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Jun 14th, 2008
0

Re: no newline at end of file error

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
micheldup is offline Offline
3 posts
since Jun 2008
Jun 14th, 2008
0

Re: no newline at end of file error

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.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Jun 14th, 2008
0

Re: no newline at end of file error

You are right, I should start studying these subjects!
Thanks a lot
Reputation Points: 10
Solved Threads: 0
Newbie Poster
micheldup is offline Offline
3 posts
since Jun 2008
May 30th, 2010
-1
Re: no newline at end of file error
only after the last command you skip a line to enter,

}
# Endif / enter
//leaving a low-lina
Reputation Points: 9
Solved Threads: 0
Newbie Poster
Jean <Brasil> is offline Offline
1 posts
since May 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Declaration Syntax Error!!!!
Next Thread in C++ Forum Timeline: Operator Overloading





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC