LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-04-2008, 08:09 AM   #1
kerenLinuxForum
LQ Newbie
 
Registered: Aug 2008
Posts: 15

Rep: Reputation: 0
Warning: no new line at the end of file


Hi.

I receicive the following Warning:
Warning: no new line at the end of file. if i Press Enter the warning disappear. However, is there anyway to disable this warning?
 
Old 09-04-2008, 08:14 AM   #2
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 485
Blog Entries: 187

Rep: Reputation: 74
Here's a quick fix:

# vi <file_that_throws_newline_error>
Then type this in order:
:$ <hit enter>
A <hit enter>
<hit enter><hit escape>
:wq <hit enter>

Or, if you prefer the simple approach:

# echo "" >> <file_that_throws_newline_error>
 
Old 09-04-2008, 08:06 PM   #3
rjenkins
LQ Newbie
 
Registered: Sep 2008
Location: ${HOME}
Distribution: Fedora
Posts: 8

Rep: Reputation: 0
Here's a link that might help: GCC Warning Options
 
Old 09-05-2008, 09:57 AM   #4
TruongAn
Member
 
Registered: Dec 2004
Location: Vietnam (Việt Nam)
Distribution: Gentoo (desktop), Arch linux (laptop)
Posts: 728

Rep: Reputation: 33
Append a newline character to everyfile MIGHT help:
Code:
echo "" >> `find -iname '*.c' -type f`
 
Old 09-08-2008, 01:32 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Just FYI, instead of

:wq <hit enter>

(write, quit)

you can just

:x <hit enter>

(exit-with-save)
 
Old 09-08-2008, 06:33 AM   #6
kerenLinuxForum
LQ Newbie
 
Registered: Aug 2008
Posts: 15

Original Poster
Rep: Reputation: 0
OK. Thanks.
 
Old 09-08-2008, 07:24 AM   #7
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by kerenLinuxForum View Post
Hi.

I receicive the following Warning:
Warning: no new line at the end of file. if i Press Enter the warning disappear. However, is there anyway to disable this warning?
This is a valid warning. Though it looks like there's a blank line at the end of your file, that's really the \n at the end of the last line. If it isn't there, gcc has to do "something special" to use that last line because technically it isn't a line.

I have such a habit of putting that newline there that I find myself putting it in all documents!
ta0kira
 
Old 09-08-2008, 08:15 AM   #8
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 485
Blog Entries: 187

Rep: Reputation: 74
Quote:
Originally Posted by chrism01 View Post
Just FYI, instead of

:wq <hit enter>

(write, quit)

you can just

:x <hit enter>

(exit-with-save)
Ahh thanks! One could use vi for years and never fully learn it's potential. Guess I need to brush up on it.

Thanks again.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
No new line at end of file? What does this mean? BajaNick Programming 12 05-19-2014 08:39 PM
C: fread to read a file line by line until the end Blue_muppet Programming 2 09-19-2008 09:42 AM
warning: no new line at end of file? Four Programming 5 01-07-2006 12:21 AM
warning: no newline at end of file huno Programming 1 07-16-2004 09:39 AM
Warning: no newline at end of file acid_kewpie Programming 1 03-13-2002 02:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration