Salt_Peter said:
The standard has nothing to do with what the OS does with the return.
That's not right. The standard dictates that EXIT_SUCCESS and 0 will be
a return that signals successful termination to the hosting
environment, regardless of what the actual values the implementation
needs. Similarly the EXIT_FAILURE macro must signal unsuccessful
termination.
The user doesn't have to be concerned with which values to return, the
implemenation has already taken care of that. If 1 is success and 0 is
failure, then the implementation will make sure that a return of 0 ends
up with the 1 the hosting evironment requires.
This aids portability, as one can then take the same code and move to
another platform with a different hosting environment, say one with 0
for success and -1 for failure, and have the code work without
modification.
Whats nice, is seeing the returned non-zero integer when you are
debugging or developing.
In all likelihood, EXIT_FAILURE is non-zero, but that's not that big of
a deal. Usually in debugging the exit value isn't all that important.
Besides, macros should not be used in C++ to define constants.
They should not be used by the USER. These are implementation macros.
If you
really need the old-time C equivalent of those macros: then use a
const int definition for these, at least that way you'll get the
appropriate type-safety.
Nonsensical. The implentation will take care of the type-safety
requirements.
const int EXIT_SUCCESS(0);
const int EXIT_FAILURE(1);
Beside illegally using system-defined things, you don't know what the
required termination code for unsuccessful exit is. That's where we
started. You don't know and should not be concerned, as that's an
implementation-specific detail. By trying to circumvent the
implementation, all you do is introduce non-portability.
These are not part of the language and an illusion since the OS gets
the integer anyways.
What aren't part of the language?
Brian