From owner-freebsd-hackers Sat May 31 21:48:01 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id VAA05662 for hackers-outgoing; Sat, 31 May 1997 21:48:01 -0700 (PDT) Received: from techunix.technion.ac.il (mellon@techunix.technion.ac.il [132.68.1.28]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id VAA05638 for ; Sat, 31 May 1997 21:47:55 -0700 (PDT) Received: (from mellon@localhost) by techunix.technion.ac.il (8.8.5/8.8.5) id HAA23448; Sun, 1 Jun 1997 07:47:41 +0300 (IDT) Message-ID: <19970601074740.37058@techunix.technion.ac.il> Date: Sun, 1 Jun 1997 07:47:40 +0300 From: Anatoly Vorobey To: hackers@freebsd.org Subject: Re: Borland 16bit bcc vs cc/gcc (float) References: <1.5.4.32.19970531220152.008b46f0@mindspring.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.64 X-Disclaimer: I was young, I needed the money! Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk You, Steve Howe, wrote on Sat, May 31, 1997 at 07:10:53PM -0800: > 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. exit() will get called anyway. When you return from main(), you return to startup code of libc, which will usually call exit(). In some C libs, you actually lose not just main()'s destructors, as the code in startup function might perform some cleaing up _before_ calling exit(), although I haven't seen this behaviour on sane systems/libs. > 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. But of course it does. The return value of main() is passed as the arg to exit() and then to the parent process. > > In fact, I've observed C++ code that never calls the destructors if you > > exit() of out a program. > > > > This is one of my favorite rants. I gave a friend of mine the 15 minute > > explanation of why void main() is wrong, and he told his instructor. She > > placed him out of her class and into the next one up. > > i'm just saying it's not an absolute. Ah, but what is an absolute? ;) A friend of mine used to despise main(). He said it was too common and wasn't creative enough. So he hacked libc to link to moose() instead of main() and his programs didn't have main() in them, which drove crazy everyone who tried to read the code. After I pointed out to him that his solution was a moral equivalent of #define moose main, he abandoned libc altogether, passing moose() as entry point directly by using an ld option, and went through a short period of using raw syscalls for i/o... -- Anatoly Vorobey, mellon@pobox.com http://pobox.com/~mellon/ "Angels can fly because they take themselves lightly" - G.K.Chesterton