Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!bcm!shell!shell!rjohnson From: rjohnson@shell.com (Roy Johnson) Newsgroups: comp.lang.c Subject: Re: main return value Message-ID: Date: 21 May 91 16:31:02 GMT References: Sender: usenet@shell.shell.com (USENET News System) Organization: Shell Development Company, Bellaire Research Center, Houston, TX Lines: 30 In-Reply-To: cschmidt@lynx.northeastern.edu's message of 12 May 1991 22:33:52 GMT In article cschmidt@lynx.northeastern.edu writes: What value should the standard function MAIN return? I ran into this question when porting some programs from DOS to VMS. Alternatives: 1. [...] 2. Declare the MAIN return type as VOID and terminate the function with the line "exit (EXIT_SUCCESS)". The problem with this is that the VAX C compiler displays an error message (warning level) when the return type of the function MAIN is VOID. How about declaring MAIN to return type INT, and terminate the function with exit(EXIT_SUCCESS); return 0; The return value of 0 will never be reached, but the compiler will not complain, and you'll always get success. [3. ... 4. ...] 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. Actually, it is possible; it's just that the interpretation of the return value is up to the platform. -- =============== !You!can't!get!here!from!there!rjohnson =============== Feel free to correct me, but don't preface your correction with "BZZT!" Roy Johnson, Shell Development Company