Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Jun 1997 10:53:26 +0100 (BST)
From:      Doug Rabson <dfr@nlsystems.com>
To:        Steve Howe <un_x@anchorage.net>
Cc:        "Kevin P. Neal" <kpneal@pobox.com>, freebsd-hackers <hackers@freebsd.org>
Subject:   Re: Borland 16bit bcc vs cc/gcc (float)
Message-ID:  <Pine.BSF.3.95q.970601105201.7076K-100000@herring.nlsystems.com>
In-Reply-To: <Pine.BSF.3.95q.970531190322.1359C-100000@aak.anchorage.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95q.970601105201.7076K-100000>