Xref: news2.mv.net comp.os.msdos.djgpp:5622 From: Eric Rudd Newsgroups: comp.os.msdos.djgpp Subject: Re: Does DJGPP conform to ANSI-C standards with the for () ? Date: 27 Jun 1996 13:11:15 GMT Organization: CyberOptics Corp Lines: 34 Message-ID: <4qu19j$d5v@hagar.cyberoptics.com> References: <199606250925 DOT NAA27938 AT video DOT yars DOT free DOT net> <31D15300 DOT 129C86C6 AT laden DOT ilk DOT de> NNTP-Posting-Host: rudd.cyberoptics.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp There have been plenty of opinions offered here, but has anyone actually consulted the ANSI spec? The relevant section is 5.1.2.2.1, where it is explained that "the implementation defines no prototype for this function [main]..." The ANSI document goes on to give an example where "main" can be defined int main(void) { /*...*/ } and specifications for the arguments argc and argv *if they are defined*. (Since they are local to main, they don't even have to be named argc and argv, but only an IOCCC entry would name them anything else.) Since the prototype is not defined in the ANSI spec, one is free to declare it void main() or even main() wherupon it defaults to type "int". In section 5.1.2.2.3, the ANSI document states "If the main function executes a return that specifies no value, the termination status returned to the host environment is undefined." It is therefore implied that "void main" is not an error. The Borland C++ compiler will flag void main() as an error if the -A (strict ANSI) switch is specified, but this is an error, since, as you see, the return type of main is *not specified* in the ANSI standard. Good programming practice is another matter. -Eric Rudd