delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/10/31/08:45:36

Message-ID: <39FECC28.D1D66D47@antlimited.com>
Date: Tue, 31 Oct 2000 13:42:00 +0000
From: Richard Heathfield <richard AT antlimited DOT com>
X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.14-5.0 i686)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: alt.comp.lang.learn.c-c++,comp.os.msdos.djgpp,comp.programming
CC: rwallace AT esatclear DOT ie
Subject: Re: Undertaking a programming journey
References: <MOqE5.2173$W31 DOT 29870 AT news1 DOT online DOT no> <8scg36$gsm$1 AT nnrp1 DOT deja DOT com> <39E9CF07 DOT 785C0C0F AT eton DOT powernet DOT co DOT uk> <8scls9$kth$1 AT nnrp1 DOT deja DOT com> <rgnjusgvadc5q9d53jticrrgdthc9af3lv AT 4ax DOT com> <39E9FAD5 DOT DE1FDAE4 AT eton DOT powernet DOT co DOT uk> <8sdrub$h7u$1 AT nnrp1 DOT deja DOT com> <39EAA40B DOT 31B0CA89 AT eton DOT powernet DOT co DOT uk> <39f5ff14 DOT 90960240 AT news DOT esatclear DOT ie> <8t4vo5$1lp$1 AT nntp9 DOT atl DOT mindspring DOT net> <39F697DB DOT E821B984 AT antlimited DOT com>
NNTP-Posting-Host: fb-ext.ant.co.uk
X-Trace: 31 Oct 2000 13:38:48 GMT, fb-ext.ant.co.uk
Lines: 52
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

[Russell's answer prompted me to re-read the thing he was answering, and
I spotted a bug...
 Courtesy copy emailed to Russell]

Richard Heathfield wrote:

<snip>

> For example, there's one OS that interprets even return codes
> as failures, and odd return codes as successes! (Is it VMS?)
> 
> Now, if you return 0 or EXIT_SUCCESS from your program, either via a
> return from main() or from exit(), a conforming C compiler guarantees
> that it will translate that value into the value interpreted by the OS
> as "success". If you return EXIT_FAILURE, the compiler guarantees that
                              ^^^^^^^^^^^^

should be EXIT_SUCCESS (!)

> it will translate /that/ value into the value interpreted by the OS as
> "failure". Thus, in the case of VMS(?), the compiler will translate
   ^^^^^^^

should be "success"

> "return 0;" into "return some odd number or other" for you, and "return
> EXIT_FAILURE;" into "return some odd number or other" (and,
  ^^^^^^^^^^^^

should be EXIT_SUCCESS

The point I was trying to make here, and failing, is that EXIT_SUCCESS
and 0 would both be translated into odd numbers for this particular OS,
but that those numbers need not be the same as each other.

> interestingly, it need not be the /same/ odd number as for "return 0"!
> (although it probably will be, I guess)). Similarly, a VMS(?) C compiler
> would ensure that "return EXIT_FAILURE" returned an even number to the
> OS.
> 
> No other values than the ones cited are semantically portable.
> 
> I hope that clarifies matters for the OP.

And I hope this clarifies matters even more. (sigh)


-- 
Richard Heathfield
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R Answers: http://users.powernet.co.uk/eton/kandr2/index.html

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019