Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Dec 2001 12:11:56 +0100
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        Harti Brandt <brandt@fokus.gmd.de>
Cc:        Mark Murray <mark@grondar.za>, John Baldwin <jhb@FreeBSD.ORG>, "David O'Brien" <obrien@FreeBSD.ORG>, cvs-all@FreeBSD.ORG, cvs-committers@FreeBSD.ORG, Luigi Rizzo <rizzo@aciri.org>, Garance A Drosihn <drosih@rpi.edu>
Subject:   Re: Are prototypes for main() illegal by any standard ? (was Re:
Message-ID:  <20011218111156.GB1464@student.uu.se>
In-Reply-To: <20011218104454.U41838-100000@beagle.fokus.gmd.de>
References:  <20011218093631.GA1096@student.uu.se> <20011218104454.U41838-100000@beagle.fokus.gmd.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Dec 18, 2001 at 11:17:34AM +0100, Harti Brandt wrote:

> ET>main should always return an int.
> 
> This is not entirely true. In the text you provide below from the C99
> draft you stripped the sentence the allows an hosted environment to define
> whatever main() function it decides to define. Appendix K.3.2 lists the
> implementation-defined behaviour for the environment:
> 
> - An alternative manner in which the main function may be defined.
> 
> But, this is just to be theoretically correct :-). Our environment defines
> main() as returning int, so correct programs should declare and define
> main() main as returning int. But, given that the compiler has no
> knowledge about main() (the text below states, that the compiler does NOT
> declare main()), it cannot give you an error.

The text says that the compiler does not supply a prototype for main().
Indeed it cannot do so, since there are *two* different forms for
main(), both of which are legal.

This does not mean that the compiler does not know anything about main().

Note that the C standard does not really make a distinction between the
C language itself and the standard library.  As far as the standard is
concerned the standard library is part of the language and the compiler
can have arbitrarily good knowledge about it.
(For example, the compiler is allowed to check if the arguments to
printf match the supplied format string and warn otherwise. Since
printf is defined by the standard, can compiler knows how it should
behave and is allowed to act on that knowledge.)




-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011218111156.GB1464>