473,382 Members | 1,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

warning : no new line at end of file

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

Dec 29 '05 #1
55 25393
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

Dec 29 '05 #2
"Sameer" <en******@gmail.com> 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) ks***@mib.org <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.
Dec 29 '05 #3
"Sameer" <en******@gmail.com> 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
Dec 29 '05 #4
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

Dec 29 '05 #5
thanks a lot. now it is working fine.

Dec 29 '05 #6
> 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
Dec 29 '05 #7
[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)
Dec 29 '05 #8
"John Smith" <js@x-formation.com> 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
Dec 29 '05 #9
could it be that you forgot void main()?!

Dec 29 '05 #10
Afifov said:
could it be that you forgot void main()?!


I hope that was intended ironically. In C, main returns int.

--
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)
Dec 29 '05 #11

Thu, Dec 29, 2005 at 10:48:30, js (John Smith) wrote about "warning : no new line at end of file":
# A source file that is not empty shall end in a new-line character

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

Because unterminated text line isn't proper text line.

JS> I personally think it's one of the most dumb restrictions ever made. Does it
JS> change anything about how the program is compiled? No! I mean, who cares
JS> about blank lines. It's the code which is important.
JS> Apple also seems to have disabled this in their version of gcc on Mac OS X.

Stock gcc doesn't require termination of last line, but warns for
its.
-netch-
Dec 29 '05 #12
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/>
Dec 29 '05 #13
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.

Dec 29 '05 #14
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.


Who is 'you'? The first post in this newsgroup occurred something
like 40 years ago, and I don't think it is available anywhere.
Some people cooperate and include proper context and attributions
in their reply articles. Other rude ones don't bother and just
waste everybodies time and bandwidth.

--
"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/>
Dec 29 '05 #15
"Afifov" <af****@yahoo.com> wrote:
you must


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

Richard
Dec 29 '05 #16
In article <43****************@news.xs4all.nl>,
Richard Bos <rl*@hoekstra-uitgeverij.nl> wrote:
"Afifov" <af****@yahoo.com> 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*.

Dec 29 '05 #17
In article <8v******************************@maineline.net> ,
Chuck F. <cb********@maineline.net> wrote:
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.


Who is 'you'? The first post in this newsgroup occurred something
like 40 years ago, and I don't think it is available anywhere.
Some people cooperate and include proper context and attributions
in their reply articles. Other rude ones don't bother and just
waste everybodies time and bandwidth.


You (and others, such as Keith) are wasting your breath. They'll never get
it. And I'll tell you why.

Imagine that there's a mouse - and the mouse is the Usenet. You and I can
see that it is a mouse and we behave accordingly. But now there is a class
of users (we'll call them "googlers") that are wearing these funny weird
glasses that make them see not a mouse, but an elephant. Seeing an
elephant (i.e., the Usenet as a web page), they also behave accordingly.
And no amount of verbiage from us is going to convince them that it's not
an elephant - that it is only a mouse.

To make this more clear, to a googler, it doesn't make any sense to "quote"
(whatever the heck that is...), in fact, to do so would be absurd, when all
the rest of the articles in the thread are right there in front of their
faces (just as clear as the trunk on that mouse, er, elephant). And no
amount of verbiage from us is going to convince them not to believe what
they see. The point is you can *never* convince someone that what they see
isn't reality. The only way you can address the problem is to help them
fix their eyesight (or help them remove their funny glasses).

Dec 29 '05 #18
In article <dp**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com>,
Richard Heathfield <in*****@invalid.invalid> 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.

Dec 29 '05 #19
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
In article <43****************@news.xs4all.nl>,
Richard Bos <rl*@hoekstra-uitgeverij.nl> wrote:
"Afifov" <af****@yahoo.com> 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
Dec 29 '05 #20
In article <43****************@news.xs4all.nl>,
Richard Bos <rl*@hoekstra-uitgeverij.nl> 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.

Dec 29 '05 #21
On Thu, 29 Dec 2005 14:57:10 GMT, ga*****@yin.interaccess.com (Kenny
McCormack) wrote:
In article <dp**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com>,
Richard Heathfield <in*****@invalid.invalid> 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
Dec 29 '05 #22
"Sameer" <en******@gmail.com> writes:
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 isn't a newline at the end of the file.

/Niklas Norrthon
Dec 29 '05 #23

Samer wrote earlier in the thread:
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 ?


"Afifov" <af****@yahoo.com> writes:
could it be that you forgot void main()?!


Please provide context!!!

May I ask why you think a warning about a missing newline would
have anything to do with "void main()" whatever that is?

By the way in C main returns int. Always!

/Niklas Norrthon

Dec 29 '05 #24
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.
Dec 29 '05 #25
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.

Dec 29 '05 #26
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
In article <43****************@news.xs4all.nl>,
Richard Bos <rl*@hoekstra-uitgeverij.nl> wrote:
>"Afifov" <af****@yahoo.com> 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) ks***@mib.org <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.
Dec 29 '05 #27

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

Dec 29 '05 #28

"John Smith" <js@x-formation.com> wrote in message
news:43**********************@dread11.news.tele.dk ...
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
Dec 29 '05 #29
>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 <11**********************@g49g2000cwa.googlegroups .com>
nelu <ta********@gmail.com> 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.
Dec 29 '05 #30
nelu wrote:
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


It is not required to be, but it is not surprising. See below...
and I
used to write return 0 in main all the time
This is perfectly valid.
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?


<snip>

The standard defines returning 0 from the initial call to main (or doing
exit(0)) indicates success. It also defines EXIT_SUCCESS and
EXIT_FAILURE which can also be used either returning from the initial
call to main or when calling exit and they have the obvious meanings.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Dec 29 '05 #31
On Thu, 29 Dec 2005 15:18:59 GMT, rl*@hoekstra-uitgeverij.nl (Richard
Bos) wrote in comp.lang.c:
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
In article <43****************@news.xs4all.nl>,
Richard Bos <rl*@hoekstra-uitgeverij.nl> wrote:
"Afifov" <af****@yahoo.com> 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


I've asked you before not to respond to this particular troll, whom I
would not see at all if it were not those, like you, who feed him.

Sorry, but *plonk*.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Dec 29 '05 #32

Flash Gordon wrote:
nelu wrote:
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


It is not required to be, but it is not surprising. See below...


I know it is not required, it was 0 on the systems I worked with. I
didn't know that return 0 should be transformed into success. Thanks!

Dec 29 '05 #33
On Thu, 29 Dec 2005 10:48:30 +0100, in comp.lang.c , "John Smith"
<js@x-formation.com> 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?


I suspect its to do with how some machines store files, and more
specifically how they know they've reached the end of a line.
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.
Its not a /blank/ line thats required, its a newline character.
Apple also seems to have disabled this in their version of gcc on Mac OS X.


Try setting warning levels a little higher.
Mark McIntyre
--

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Dec 30 '05 #34
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
In article <43****************@news.xs4all.nl>,
Richard Bos <rl*@hoekstra-uitgeverij.nl> wrote:
...
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.


Be grateful for small mercies: trolls would take precedence.

Richard
Dec 30 '05 #35
i am amazed how some of u have so much time for these long posts. some of
us have to work.

Dec 30 '05 #36
On 2005-12-29, Richard Bos <rl*@hoekstra-uitgeverij.nl> wrote:
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
In article <43****************@news.xs4all.nl>,
Richard Bos <rl*@hoekstra-uitgeverij.nl> wrote:
>"Afifov" <af****@yahoo.com> 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


And besides, quoting is common on web boards. It's generally done with a
blockquote-like bbcode tag, but is still done nonetheless.
Dec 30 '05 #37
On 2005-12-29, John Smith <js@x-formation.com> 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?

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.


What is your evidence for this claim?

note that this does not mean that it should end with a blank line.
Traditionally, every line of a text file ends in a newline character. I
suspect the editors you are using on OSX provide it. This doesn't mean
there is a blank line

There is a newline at the end of this post [technically a carriage
return and a linefeed, since that's how text-based network protocols
tend to do things.]
Dec 30 '05 #38
Jordan Abel <ra*******@gmail.com> writes:
On 2005-12-29, John Smith <js@x-formation.com> 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?

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.


What is your evidence for this claim?

note that this does not mean that it should end with a blank line.
Traditionally, every line of a text file ends in a newline character. I
suspect the editors you are using on OSX provide it. This doesn't mean
there is a blank line

There is a newline at the end of this post [technically a carriage
return and a linefeed, since that's how text-based network protocols
tend to do things.]


Whether a text file includes a proper newline on its last line can
depend on which text editor you used to create it.

Discussion of questionable topicality follows (it's topical in
comp.unix.programmer, but at best marginally so in comp.lang.c).

On Unix-like systems, most or all versions of vi (vi, nvi, vim, etc.)
add a newline automatically. If you edit a file that lacks a trailing
newline, it will add one when you update the file. As far as I know,
it's nearly impossible to create a mal-formed text file with vi.

The behavior of emacs, on the other hand, can be configured by setting
the "require-final-newline" variable. By default, emacs will silently
create a file with no trailing newline. It can also be configured
either to silently add a newline, or to ask what to do. I have the
line
(setq require-final-newline 'ask)
in my $HOME/.emacs file.

Other systems and other editors will have different ways of handling
this.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <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.
Dec 30 '05 #39
On Fri, 30 Dec 2005 10:21:35 -0500, in comp.lang.c , "Afifov"
<af****@yahoo.com> wrote:
i am amazed how some of u have so much time for these long posts. some of
us have to work.


Perhaps some of yuo ought to consider a job that allows you to take
paid holidays, and doesn't require you to work evenings and weekends.
:-)

Mark McIntyre
--

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Dec 30 '05 #40

Keith Thompson wrote:
On Unix-like systems, most or all versions of vi (vi, nvi, vim, etc.)
add a newline automatically. If you edit a file that lacks a trailing
newline, it will add one when you update the file. As far as I know,
it's nearly impossible to create a mal-formed text file with vi.

The behavior of emacs, on the other hand, can be configured by setting
the "require-final-newline" variable. By default, emacs will silently
create a file with no trailing newline. It can also be configured
either to silently add a newline, or to ask what to do. I have the
line
(setq require-final-newline 'ask)
in my $HOME/.emacs file.

Other systems and other editors will have different ways of handling
this.


Excuse me for being off-topic, just for a second, but, just out of
curiosity, what editor is the most used on clc?

Dec 31 '05 #41
> What is your evidence for this claim?

note that this does not mean that it should end with a blank line.
Traditionally, every line of a text file ends in a newline character. I
suspect the editors you are using on OSX provide it. This doesn't mean
there is a blank line


Evidence? How about my eyes and fingers to type with? I've been using OS X
10.3 for the last year and also 10.4 for some months. I initially ported
some software for OS X and didn't even know about the new line issue until I
went on porting it to linux. So this behaviour is the same for both gcc 3.x
and 4.x provided on OS X.

I havn't actually used the editors on OS X. Most of my code has been just
cross developed. I work on one machine and compile on another.

-- John
Dec 31 '05 #42
On 2005-12-31, John Smith <js@x-formation.com> wrote:
What is your evidence for this claim?

note that this does not mean that it should end with a blank line.
Traditionally, every line of a text file ends in a newline character. I
suspect the editors you are using on OSX provide it. This doesn't mean
there is a blank line


Evidence? How about my eyes and fingers to type with? I've been using OS X
10.3 for the last year and also 10.4 for some months. I initially ported
some software for OS X and didn't even know about the new line issue until I
went on porting it to linux. So this behaviour is the same for both gcc 3.x
and 4.x provided on OS X.

I havn't actually used the editors on OS X. Most of my code has been just
cross developed. I work on one machine and compile on another.


evidence would be, for example, a hexdump of a file that you think does
not end in a newline, that OSX gcc accepts.
Dec 31 '05 #43
How do you explain the exit codes of "grep"?

Dec 31 '05 #44
"tmp123" <tm****@menta.net> writes:
How do you explain the exit codes of "grep"?


Surely you've seen <http://cfaj.freeshell.org/google/>. That URL has
been posted to this newsgroup 127 times in the last month (according
to Google). If you don't provide some context, don't expect anyone to
know what you're talking about -- and don't expect anyone to go to the
extra effort to find out.

"grep" is a system-specific program. It exists on Unix-like systems,
and there are undoubtedly implementations of it on other systems. It
is therefore off-topic. If you want to understand its exit codes, you
should read the documentation that should be available on any system
that has the command.

If you're wondering why the exit codes aren't limited to 0,
EXIT_SUCCESS, and EXIT_FAILURE, there's no particular reason why they
should be. If exit() is called with any other value, the status
returned is implementation-defined. Since the "grep" command is
implementation-specific, that's perfectly appropriate. It's not even
required that "grep" is implemented in C or uses exit(). (If "grep"
were ported to VMS, presumably the exit codes would have to be
changed.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <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.
Dec 31 '05 #45
>"grep" is a system-specific program. It exists on Unix-like systems,
and there are undoubtedly implementations of it on other systems. It
is therefore off-topic. If you want to understand its exit codes, you
should read the documentation that should be available on any system
that has the command.

If you're wondering why the exit codes aren't limited to 0,
EXIT_SUCCESS, and EXIT_FAILURE, there's no particular reason why they
should be. If exit() is called with any other value, the status
returned is implementation-defined. Since the "grep" command is
implementation-specific, that's perfectly appropriate. It's not even
required that "grep" is implemented in C or uses exit(). (If "grep"
were ported to VMS, presumably the exit codes would have to be
changed.)


There are a lot of programs whose job is to test something, where
the result is necessarily three-way (or more than three):

test result is true
test result is false
unable to conduct test (possibly subdivided into: bad test syntax,
file open failed, division by zero, unable to log into database, etc.)

How you map that into EXIT_SUCCESS, EXIT_FAILURE, and other
allowed exit codes that aren't either is up to you.
Exit codes that *SHOULD* have been standardized, but aren't:

EXIT_SUCCESS_WITH_PROMOTION_AND_RAISE
EXIT_SUCCESS_YOU_GET_TO_KEEP_YOUR_JOB
EXIT_FAILURE_YOU_ARE_FIRED
EXIT_FAILURE_AND_YOU_WILL_BE_EXECUTED_BY_FIRING_SQ UAD

Gordon L. Burditt
Dec 31 '05 #46
On 30 Dec 2005 19:38:18 -0800, in comp.lang.c , "nelu"
<ta********@gmail.com> wrote:
Excuse me for being off-topic, just for a second, but, just out of
curiosity, what editor is the most used on clc?


If you have a new question, start a new thread, and don't x-post to an
unrelated group.
Mark McIntyre
--

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jan 1 '06 #47
On 31 Dec 2005 11:00:20 -0800, in comp.lang.c , "tmp123"
<tm****@menta.net> wrote:
How do you explain the exit codes of "grep"?


In iambic pentameter.

(since you provided absolutely no context, I chose to interpret your
question as "using what delivery style...")

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jan 1 '06 #48
Mark McIntyre said:
On 31 Dec 2005 11:00:20 -0800, in comp.lang.c , "tmp123"
<tm****@menta.net> wrote:
How do you explain the exit codes of "grep"?


In iambic pentameter.


Your wish is my command.

Now grep has quite a wonderful design,
And purposes untold and without number;
When searching for that quintessential line,
You know your trusty grep will never slumber,
Seeking, seeking, all throughout its sessions,
With full support for regular expressions.

But if you execute it from a shell script,
Wanting total searching automation,
You really need a way that you can decrypt
Those exit codes, a most complete translation.
Here's a guide to help you understand them,
So that you need not yet all hope abandon:

When grep yields zero, questing is completed,
And nothing sought remains to be disclosed;
But if our hero hands you one, defeated,
No answer is there to the search you posed;
And when your shell script with a two is treated,
Your files are wrong, or your argv is hosed.

--
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)
Jan 1 '06 #49
[Followups set to comp.lang.c]

nelu said:
Excuse me for being off-topic, just for a second, but, just out of
curiosity, what editor is the most used on clc?


In comp.lang.c, that's a bit like asking "what colour socks do C hackers
prefer?" Yes, there is an answer, but no, you'll probably never find out
what it is, because comp.lang.c subscribers don't actually care what the
answer is.

The comp.unix.programmer and comp.lang.c newsgroups have good historical
reasons for being fluffy-bunny snuggly companions, but in practice C has
spread far and wide since those halcyon days of the 1973 kernel, and the
comp.lang.c group no longer thinks of C as being merely another word for
Unix. I've hacked out C code in ISPF/PDF, Notepad, vim, elvis, pico, and
a variety of Windows IDEs. I've written C using COPY CON and cat. I have
written C code using custom-written code generators - which can scarcely
count as editors at all. Here in comp.lang.c, the question is simply not
worth asking, I'm afraid.

--
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)
Jan 1 '06 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: thule | last post by:
Okay, thanks to John (THANK YOU SO MUCH). I switched all my header files over to using the new Standard <iostream> and included the using namespace std; . This seems to have fixed all the errors I...
40
by: Dave Hansen | last post by:
Please note crosspost. Often when writing code requiring function pointers, it is necessary to write functions that ignore their formal parameters. For example, a state machine function might...
3
by: Bill Burris | last post by:
How do I find what is causing this warning from the Linker? If I use /NODEFAULTLIB I get hundreds of undefined symbols. LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other...
10
by: moondaddy | last post by:
I converted a vb.1.1 web service project to 2.0 and .net 2.0 created / replace some datasets. The code it automatiacly generated gets a warning message as follows: Warning 150 Name...
19
by: lawrence k | last post by:
How can I find out where my script is outputting to the screen for the first time? My error logs are full of stuff like this: PHP Warning: session_start(): Cannot send session cache...
0
by: Manish | last post by:
PHP INI File Setting ------------------------------------------------------------------------------------------------------------------ error_reporting = E_ALL & ~E_NOTICE No warning message are...
3
by: siyaverma | last post by:
i am trying to upload csv file from user's computer to main server the code i am using is if(((isset($_GET)) && ($_GET=="yes")) ) { $typefield = $_GET; echo...
8
by: benn | last post by:
Here's the setup... Defines.h file contains: enum DAY { monday, tueday }; DayFunctions.h contains prototype: void printIsMonday ( enum DAY currentDay); DayFunctions.c contains:
9
by: awagner | last post by:
I am compiling a C application on an HP Unix 11.23 platform using the C99 compiler. I am receiving the following three warning message from the /usr/include/sys/_mbstate_t.h include file. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.