Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Compilation problems??

Re: Compilation problems??

From: Markus Mattes <mmattes_at_rz-onlineR.de>
Date: 1997/08/16
Message-ID: <33f476a4.4060088@news.rhein-zeitung.de>#1/1

On Thu, 14 Aug 1997 19:58:20 -0400, Alicia Carla Longstreet <carla_at_ici.net> wrote:

>> However a program which exits with a status other than 0, EXIT_SUCCESS,
>> or EXIT_FAILURE is not a strictly-conforming C program. The behavior
>> of exit statuses not mentioned above is implementation-defined, i.e,
>> on one platform "exit(1);" might indicate success, on another it might
>> indicate failure, and on yet another it might even indicate that the
>> program "almost worked."
 

>Which is patently absurd. When I write a program, I, not the standard,
>not you or anybody else, decide what the exit codes mean.

ANSI/ISO 9889-1990 states:

[...]
7.10.4.3 The exit function

[...]
Finally, control is returned to the host environment. If the value of status is zero or EXIT_SUCCESS, an implementation-defined form of the status sucessful termination is returned. If the value of status is EXIT_FAILURE, an implementation-defined form of the status unsuccessful termination is returned. Ohterwise the status returned is implementation-defined.

>Exit codes
>often specify what went wrong, or possibly, most any exit code is a code
>for sucess. The Standard defines three exit codes to be used when the
>programmer has no desire or need to provide exit codes of his/her own
>specification.

Well, read the standard carefully. ;-)

>Exit codes are NEVER implementation defined, they are ALWAYS defined by
>the programmer and should be specified in the documentation.

Exit codes are EVER implementation defined, the trick is, that an exit code of 0, EXIT_SUCCESS or EXIT_FAILURE, returns a well defined status ( program exited with a fail / program exited sucessful ), while any other exit code may return a status which may be no more in your hands.

>If I write a program and decide that exit(99) indicates failure due to
>an inability to allocate sufficient memory for a data object, that is
>EXACTLY what an exit code of 99 will mean ON EVERY SINGLE PLATFORM/OS
>THAT I CHOOSE TO PORT MY PROGRAM TO.
Sorry, but you are wrong here. If you return the value 99 and EXIT_SUCCESS or EXIT_FAILURE just happen to be not defined as 99 the implementation might as well return 42 to the host environment which might be interpreted as "shut down the nuclear plant, a program went wild".

If you know exactly that your current implementation and host environment just get the same value you returned, this is just fine, but you can't be sure that this will be the case for ALL implementations/OS being.

ByE, MarKus.

( To reply by e-mail remove the 'R' in my e-mail address ) Received on Sat Aug 16 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US