From owner-freebsd-hackers Sun Jun 1 02:53:48 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id CAA16428 for hackers-outgoing; Sun, 1 Jun 1997 02:53:48 -0700 (PDT) Received: from nlsystems.com (nlsys.demon.co.uk [158.152.125.33]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id CAA16421 for ; Sun, 1 Jun 1997 02:53:45 -0700 (PDT) Received: from herring.nlsystems.com (herring.nlsystems.com [10.0.0.2]) by nlsystems.com (8.8.5/8.8.5) with SMTP id KAA21515; Sun, 1 Jun 1997 10:53:26 +0100 (BST) Date: Sun, 1 Jun 1997 10:53:26 +0100 (BST) From: Doug Rabson To: Steve Howe cc: "Kevin P. Neal" , freebsd-hackers Subject: Re: Borland 16bit bcc vs cc/gcc (float) In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk On Sat, 31 May 1997, Steve Howe wrote: > > On Sat, 31 May 1997, Kevin P. Neal wrote: > > > >ahhh! :) everyone says this - but exit() never returns, so main > > >never returns anything, so IMHO, main should always be type void. > > > Who says you always have to use exit()? > > i'm sorry, i meant if you use exit. i spent alot of time writing BIOS's > for embedded systems where i had to sqeeze out every meaningless opcode, > and i found that if return codes generate quite a few opcodes, which is a > waste if your bootstrapping and jumping to an OS which will create it's > own stack. further, from what i gather, it's good to call exit() on a > real OS when you finish a program in case there a hidden/extraneous > clean-up functions that need to be completed. and since exit doesn't > return to main, any return in main is a waste of code. it might also give > someone the wrong idea that main actually does return something. >From crt0.c: ... exit(main(kfp->kargc, argv, environ)); ... As you can see, exit() gets called with the result returned from main. All clean-ups happen as one would expect. Anything less would be a bug and would be fixed. -- Doug Rabson Mail: dfr@nlsystems.com Nonlinear Systems Ltd. Phone: +44 181 951 1891 Fax: +44 181 381 1039