From owner-cvs-all Tue Dec 18 1:35:31 2001 Delivered-To: cvs-all@freebsd.org Received: from mailhub.fokus.gmd.de (mailhub.fokus.gmd.de [193.174.154.14]) by hub.freebsd.org (Postfix) with ESMTP id C6F9737B42F; Tue, 18 Dec 2001 01:35:06 -0800 (PST) Received: from beagle (beagle [193.175.132.100]) by mailhub.fokus.gmd.de (8.11.6/8.11.6) with ESMTP id fBI9Z2505228; Tue, 18 Dec 2001 10:35:03 +0100 (MET) Date: Tue, 18 Dec 2001 10:35:02 +0100 (CET) From: Harti Brandt To: Mark Murray Cc: John Baldwin , "David O'Brien" , , , Luigi Rizzo , Garance A Drosihn Subject: Re: Are prototypes for main() illegal by any standard ? (was Re: In-Reply-To: <200112180848.fBI8mvO00685@grimreaper.grondar.org> Message-ID: <20011218102348.W5601-100000@beagle.fokus.gmd.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 18 Dec 2001, Mark Murray wrote: MM>> > This is comming up due to a bug in a single compiler. We have fixed that MM>> > compiler. AFAIK the other two compilers we use at all today -- TenDRA MM>> > and Compaq's compiler does not have this bug. So why change all this MM>> > code when we fixed things at the source of the problem? MM>> MM>> Agreed. Requesting prototypes for main is the compiler bug, not hiding the MM>> warning for main. MM> MM>This I do not understand. :-) MM> MM>AFAIK, this is perfectly legal C: MM> MM>/* begin */ MM>void printf(char *, ...) MM> MM>void main(void) MM>{ MM> printf("Hello world"); MM>} MM>/* end */ MM> MM>And it should compile warning-free and run without error. Agreed MM>that the style sucks, but it is _legal_ - and any compiler's prior MM>assumed knowledge about main is plain wrong - it is a linker thing MM>to use ``main'' as an entry point, and nobody else's damn business MM>what it is after that! (argc and argv are likewise conventions that MM>are less useful in an embedded environment with no shell (ya, ya I MM>know about execv :)). MM> MM>Now if anyone can show official standards showing me that I'm MM>wrong here, I'll shut up and back off. :-) Clause 1 of section 5.1.2.2.1 of my ISO-C draft states that in a hosted (not freestanding environment): "The function called at program startup is named main. The implementation declares no prototype for this function. It shall be defined with a return type of int and with no parameters: int main(void) { /* ... */ } or with two parameters (referred to here as argc and argv, though any names may be used, as they are local to the function in which they are declared): int main(int argc, char *argv[]) { /* ... */ } or equivalent; or in some other implementation-defined manner." Up to now I was under the impression, that the compiler should have an implicit prototype for main(). But the second sentence above states that it does not. As I understand the wording, Mark is right. harti -- harti brandt, http://www.fokus.gmd.de/research/cc/cats/employees/hartmut.brandt/private brandt@fokus.fhg.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message