main return value

Richard A. O'Keefe ok at goanna.cs.rmit.oz.au
Mon May 13 15:59:54 AEST 1991


In article <memo.1010816 at lynx.northeastern.edu>, cschmidt at lynx.northeastern.edu writes:
> 3.  Declare the MAIN return type as INT and terminate the function
>     with the line "return EXIT_SUCCESS".  The problem with this is
>     that EXIT_SUCCESS is zero, even in the VAX version, and when a VMS
>     program terminates and returns zero to VMS, VMS displays the
>     system message for status code zero.  (The universal status code
>     for success in VMS is one, not zero.)

The whole _point_ ofg having EXIT_SUCCESS and EXIT_FAILURE in the
standard is so that they can be configured for the host operating system.
If a C implementation defines EXIT_SUCCESS to be something that provokes
an error, that implementation is _broken_.  You may have to provide your
own header #defining EXIT_SUCCESS correctly.

However, I note that VMS was hacked a couple of years ago so that a 0
return from a C program would _not_ provoke an error report from DCL.
Are you running a current version of VMS?

> I expect many experienced C programmers will be surprised to learn
> that it is impossible to write a portable, lint-free "hello world"
> program in C that compiles and links without errors.

Not at all.  There is no limit to the way compilers can be broken.
(Example: A certain C compiler for M680x0s used to emit the right
opcode for a certain unsigned comparison, but the assembler (from
the same vendor) that was its back end reversed the sense...)

-- 
Bad things happen periodically, and they're going to happen to somebody.
Why not you?					-- John Allen Paulos.



More information about the Comp.lang.c mailing list