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

 
 
Kenny McCormack
Guest
Posts: n/a
 
      12-29-2005
In article <dp0cma$gj4$(E-Mail Removed)-infra.bt.com>,
Richard Heathfield <(E-Mail Removed)> wrote:
>[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.


Let's see... How does one spell "pedant" ?

P.S. To Mr. Smith, the reason is that it doesn't matter on Unix and other
well-behaved OS's, but it might matter elsewhere. Or, to put it another
way, it should be possible to write the compiler front-end in (100%)
standard C, and standard C requires that text files be well-behaved.

 
Reply With Quote
 
 
 
 
Richard Bos
Guest
Posts: n/a
 
      12-29-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) (Kenny McCormack) wrote:

> In article <(E-Mail Removed)4all.nl>,
> Richard Bos <(E-Mail Removed)> wrote:
> >"Afifov" <(E-Mail Removed)> wrote:
> >
> >> you must

> >
> >_Who_ must? Learn to quote context! This is not a web board where
> >anything goes.

>
> From his point of view, it *is*.


Since when is that any excuse? From my POV, Google is a parasite, but
that doesn't justify me taking bugspray to its owners.

Richard
 
Reply With Quote
 
 
 
 
Kenny McCormack
Guest
Posts: n/a
 
      12-29-2005
In article <(E-Mail Removed)4all.nl>,
Richard Bos <(E-Mail Removed)> wrote:
....
>> >_Who_ must? Learn to quote context! This is not a web board where
>> >anything goes.

>>
>> From his point of view, it *is*.

>
>Since when is that any excuse?


It is not an excuse. I really don't see where you (and others) get the idea
that I am excusing anyone.

It is, rather, an *explanation*, and a suggestion to you, the regulars,
that you find other ways to deal with it. The point is, as I explain every
time I post my little treatise on the subject, you simply *cannot* convince
someone that what they see isn't reality.

>From my POV, Google is a parasite, but
>that doesn't justify me taking bugspray to its owners.


I think we'd all be much happier if you did.

 
Reply With Quote
 
Al Balmer
Guest
Posts: n/a
 
      12-29-2005
On Thu, 29 Dec 2005 14:57:10 GMT, (E-Mail Removed) (Kenny
McCormack) wrote:

>In article <dp0cma$gj4$(E-Mail Removed)-infra.bt.com>,
>Richard Heathfield <(E-Mail Removed)> wrote:
>>[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.

>
>Let's see... How does one spell "pedant" ?


It's spelled "computer program" or "parser." Computers tend to be very
pedantic, and not recognize even trivial deviations from the rules
they live by.
>
>P.S. To Mr. Smith, the reason is that it doesn't matter on Unix and other
>well-behaved OS's, but it might matter elsewhere. Or, to put it another
>way, it should be possible to write the compiler front-end in (100%)
>standard C, and standard C requires that text files be well-behaved.


It's not the OS, but whether the compiler accepts EOF as equivalent to
newline in that context.

Whether the compiler can reliably do that may depend on the OS, or
more exactly, the file system.

--
Al Balmer
Sun City, AZ
 
Reply With Quote
 
Martin Ambuhl
Guest
Posts: n/a
 
      12-29-2005
Afifov wrote:
> could it be that you forgot void main()?!


What the hell is this about?

If you mean that someone should delare main to have a return type of
void, then you are severely in error.

If you mean he should void such code into the porcelon throne, then you
are probalby right.
 
Reply With Quote
 
Martin Ambuhl
Guest
Posts: n/a
 
      12-29-2005
Afifov wrote:
> you must declare main to be int and return 0. The person with the first
> post excluded the return statement, which i was referring to.


main may also return EXIT_FAILURE and EXIT_SUCCESS. For
implemetation-specific non-portable code, other implementation-defined
values are possible. It is not true that main must return 0.

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      12-29-2005
(E-Mail Removed) (Richard Bos) writes:
> (E-Mail Removed) (Kenny McCormack) wrote:
>> In article <(E-Mail Removed)4all.nl>,
>> Richard Bos <(E-Mail Removed)> wrote:
>> >"Afifov" <(E-Mail Removed)> wrote:
>> >
>> >> you must
>> >
>> >_Who_ must? Learn to quote context! This is not a web board where
>> >anything goes.

>>
>> From his point of view, it *is*.

>
> Since when is that any excuse? From my POV, Google is a parasite, but
> that doesn't justify me taking bugspray to its owners.


Please don't feed the troll. Thank you.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <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
 
nelu
Guest
Posts: n/a
 
      12-29-2005

Martin Ambuhl wrote:
> main may also return EXIT_FAILURE and EXIT_SUCCESS. For
> implemetation-specific non-portable code, other implementation-defined
> values are possible. It is not true that main must return 0.


I know that EXIT_SUCCESS==0 on all the platforms I've used C on and I
used to write return 0 in main all the time but since the C standard
defines EXIT_SUCCESS and EXIT_FAILURE in <stdlib.h> and they should be
used by 'exit' is it correct (not program correctness, but C standard)
to ever explicitly return 0?
I got used to 0 from Visual C++ 5, I think, and I noticed that the
KDevelop template for the main function in a C program terminates with
'return EXIT_SUCCESS'.

 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a
 
      12-29-2005

"John Smith" <(E-Mail Removed)> wrote in message
news:43b3b125$0$1791$(E-Mail Removed) ...

>> 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?


So that you can concatenate files together without lines merging.

> 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.


It does change things about how the program is compiled. Your assumption
is erroneous. Failure to end a file with a newline could result in
concatenating two files, causing the last symbol in one to merge with the
first symbol in the next.

The other reason is simply for logical consistency. A line is defined to
end with a specific line ending character. A source file is defined to
consist of lines.

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


They are not required to issue a warning.

DS


 
Reply With Quote
 
Chris Torek
Guest
Posts: n/a
 
      12-29-2005
>Martin Ambuhl wrote:
>> main may also return EXIT_FAILURE and EXIT_SUCCESS. For
>> implemetation-specific non-portable code, other implementation-defined
>> values are possible. It is not true that main must return 0.


In article <(E-Mail Removed) .com>
nelu <(E-Mail Removed)> wrote:
>I know that EXIT_SUCCESS==0 on all the platforms I've used C on ...


It happens to be defined as 1 on VMS (where 1 is the general-purpose
OS "success" code).

>... is it correct (not program correctness, but C standard)
>to ever explicitly return 0?


It is valid to do so. A Standard C system must convert an exit(0),
or the (mostly) equivalent "return 0" from initial call to main, into
(one of) the OS's "success" code(s). On VMS in particular, this
means that exit(0) and exit(1) do the same thing.

(Older, pre-ANSI-C-standard versions of VMS fail to convert 0 to 1,
so that in VMS 3.0, returning 0 from a C program causes the system
to claim the program failed.)

If the OS happens to have two or more different "kinds" of "success",
a C implementation for that OS is allowed to have EXIT_SUCCESS
produce one of them and 0 produce another (different) one.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
 
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