Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: main return value Message-ID: <5706@goanna.cs.rmit.oz.au> Date: 13 May 91 05:59:54 GMT References: Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 30 In article , cschmidt@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.