From -760739197640074814
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,314ebdf2ff957e27
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-04-15 17:01:38 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: kanze@gabi-soft.de (James Kanze)
Newsgroups: comp.std.c++
Subject: Re: Why int main()?
Date: Wed, 16 Apr 2003 00:01:37 +0000 (UTC)
Organization: http://groups.google.com/
Lines: 53
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <d6651fb6.0304150039.67fdce42@posting.google.com>
References: <Qbvla.955$5Z2.28625@newsfep1-win.server.ntli.net> <RkkxdPDmqwl+Ewp6@robinton.demon.co.uk> <3E9821CE.8AC8B8C6@web.de>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: mail2news.demon.co.uk 1050451297 23630 10.0.0.1 (16 Apr 2003 00:01:37 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Wed, 16 Apr 2003 00:01:37 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.12)
	id 195aMq-00068q-00
	for mail2news@news.news.demon.net; Wed, 16 Apr 2003 00:01:36 +0000
X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU
	id KAA11145; Wed, 16 Apr 2003 10:01:31 +1000 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ucar.edu
X-Newsgroups: comp.std.c++
X-NNTP-Posting-Date: 15 Apr 2003 08:39:47 GMT
X-Spamscanner: mailbox3.ucsd.edu  (v1.2 Mar 17 2003 15:04:36, -0.4/5.0 2.43)
X-MailScanner: PASSED (v1.2.7 25620 h3F8dlJC031191 mailbox3.ucsd.edu)
X-Spam-Status: No, hits=-9.2 required=5.0
	tests=EMAIL_ATTRIBUTION,NOSPAM_INC,QUOTED_EMAIL_TEXT,REFERENCES,
	      SPAM_PHRASE_00_01
	version=2.41
Xref: archiver1.google.com comp.std.c++:18764

terekhov@web.de (Alexander Terekhov) wrote in message
news:<3E9821CE.8AC8B8C6@web.de>...
> Francis Glassborow wrote:

> > In article <Qbvla.955$5Z2.28625@newsfep1-win.server.ntli.net>, Huw Ford
> > <Huw@Tesco.net> writes
> > >A lot of compilers will accept "void main()" so why must main
> > >return an int?

> > Because Standards are about portability. ....

> In the next round, I'd probably try to make {thread::}main's return
> type "application-chosen" -- other thread(s) (if any) could then join
> and obtain whatever-return-value (if it's not void)... and adopt a
> rather simple POSIX behavior of "passive exit" on last thread
> termination. Oder? ;-)

Interesting point of view.  There are several interesting points, in
fact:

  - Why int?  That's what Unix and MS-DOS used, but it certainly isn't
    universal.  The logical solution would have been an implementation
    defined type, main_t with only the return of the macros EXIT_SUCCESS
    and EXIT_FAILURE guaranteed by the standard.  That would have broken
    a lot of existing programs, however.

  - Why not allow void?  Either define falling off the end of a void
    main as equivalent to return EXIT_SUCCESS from a non-void main, or
    say that any return value is undefined (which is what actually
    happens in most implementations today).  Or say that returning from
    a void main is illegal (undefined behavior) -- generally, when
    people write void main, it is because they don't return, either
    because the program consists of an endless loop, or because they
    always call exit.

  - And the business of threads introduces additional issues.  Posix
    threads return a void*, for example, and not an int.  Logically, I
    would expect a process to act sort of like a thread in the overall
    system, with a similar sort of return value.  On the other hand,
    existing practice...

--
James Kanze             GABI Software             mailto:kanze@gabi-soft.fr
Conseils en informatique orient�e objet/
                           Beratung in objektorientierter Datenverarbeitung
11 rue de Rambouillet, 78460 Chevreuse, France, T�l. : +33 (0)1 30 23 45 16

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



