Mail Archives: djgpp/2000/10/31/08:45:36
[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 -