From owner-freebsd-hackers Fri Sep 6 08:31:00 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id IAA01335 for hackers-outgoing; Fri, 6 Sep 1996 08:31:00 -0700 (PDT) Received: from who.cdrom.com (who.cdrom.com [204.216.27.3]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id IAA01325 for ; Fri, 6 Sep 1996 08:30:57 -0700 (PDT) Received: from dub-img-4.compuserve.com (dub-img-4.compuserve.com [149.174.206.134]) by who.cdrom.com (8.7.5/8.6.11) with SMTP id HAA21603 for ; Fri, 6 Sep 1996 07:31:17 -0700 (PDT) Received: by dub-img-4.compuserve.com (8.6.10/5.950515) id KAA24569; Fri, 6 Sep 1996 10:25:45 -0400 Date: 06 Sep 96 10:19:20 EDT From: Jan Knepper <100626.3506@CompuServe.COM> To: "[FreeBSD Hackers]" Subject: Re: void main Message-ID: <960906141919_100626.3506_BHL134-1@CompuServe.COM> Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk /* > Strictly speaking, there are exactly two correct versions of main(): > > int main(void); > > and > > int main(int argc, char *argv[]); > What's wrong with this version? ;-) int main (int argc, char *argv[], char *env[]); */ Proza from the C++ Draft April 18 1995, Doc No:X3J16/95-0087: 3.6.1 Main function [basic.start.main] 1 A program shall contain a global function called main, which is the designated start of the program. 2 This function is not predefined by the implementation, it cannot be overloaded, and its type is implementation-defined. All implementations shall allow both of the following definitions of main: int main() { /* ... */ } and int main(int argc, char* argv[]) { /* ... */ } In the latter form argc shall be the number of arguments passed to the program from the environment in which the program is run. If argc is nonzero these arguments shall be supplied in argv[0] through argv[argc-1] as pointers to the initial characters of null-terminated multibyte strings (NTMBSs) and argv[0] shall be the pointer to the initial character of a NTMBS that represents the name used to invoke the program or "". The value of argc shall be nonnegative. The value of argv[argc] shall be 0. [Note: It is recommended that any further (optional) parameters be added after argv. ] 3 The function main() shall not be called from within a program. The linkage (_basic.link_) of main() is implementation-defined. The address of main() shall not be taken and main() shall not be declared inline or static. The name main is not otherwise reserved. [Example: member functions, classes, and enumerations can be called main, as can entities in other namespaces. ] 4 Calling the function void exit(int); declared in (_lib.support.start.term_) terminates the pro- gram without leaving the current block and hence without destroying any objects with automatic storage duration (_class.dtor_). The argu- ment value is returned to the program's environment as the value of the program. 5 A return statement in main() has the effect of leaving the main func- tion (destroying any objects with automatic storage duration) and calling exit() with the return value as the argument. If control reaches the end of main without encountering a return statement, the effect is that of executing return 0; Don't worry, be Kneppie, Jan