Article View: comp.std.c
Article #4988Re: int main(void) or int main()?
From: Frank DENIS (Jedi/Sector One)
Date: Fri, 05 Apr 1996 12:46
Date: Fri, 05 Apr 1996 12:46
42 lines
2353 bytes
2353 bytes
In article <4k17gf$gob@isoit109.bbn.hp.com>, Bruno RICHARD <bruno_richard@hp-france-om1.om.hp.com> writes: -=)> What is the recommended declaration for a function that does -=)> not take arguments and does not return anything: -=)> void myfunc(); -=)> or -=)> void myfunc(void); The second one is definitely better, as the first one as different meanings according to the C style you're conforming to : - In K&R, () means "gimme anything as parameters, I won't care" - In ANSI C, it should be avoided - In ANSI C++, it means "this functions takes NOTHING" As K&R is a bit obsolete and the (void) notation works in ANSI C as well as C++, you'd better use this form that is BTW more explicit than nothing and should be interpreted the same way by any modern C compiler. -=)> I remember that few years ago on Turbo C 2.0 the second form was better -=)> optimized. So I got used to do so, but I just read the C FAQ and noticed -=)> that there was some argument about main() returning int or void, main returns an INT and takes zero or two arguments. Nothing else. But well, Turbo C is pretty lame to produce a less efficient code in the second case anyway. Use DJGPP, it rocks ! Your code will be at least 3 times faster than with Turbo C ( Turbo, eh eh... ) and GCC is a bit more ISO 9899 conformant than Borland shits. -=)> and -=)> I am wondering whether there could be some portability problems around. -=)> -bruno Best regards, Frank. -- .-=)> Frank DENIS aka JEDI from SECTOR ONE ( j@nether.net ) <(=-. \ Serveur minitel RTC-One au prix d'une simple communication sur Paris : / ) (1) 48.70.10.29 ou (1) 48.58.46.17 - Messagerie, HP48, PC, delires, ... ( ( Acces 28800 bauds au (1) 49.88.76.91 . Informations: email j@nether.net ) \_-^-_. Mon pere est un vieux con ._-^-_/
Technical Details
Message-ID:
<4k34n3$qvt@boson.epita.fr>Path:
arc1-ca.pugleaf.net!tank.news.pipex.net!pipex!oleane!epita!photon!denis_rReferences:
<4k17gf$gob@isoit109.bbn.hp.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!tank.news.pipex.net!pipex!oleane!epita!photon!denis_r From: denis_r@epita.fr (Frank DENIS (Jedi/Sector One)) Newsgroups: comp.std.c Subject: Re: int main(void) or int main()? Date: 5 Apr 1996 12:46:27 GMT Organization: Epita (French engineering school) Distribution: world Message-ID: <4k34n3$qvt@boson.epita.fr> References: <4k17gf$gob@isoit109.bbn.hp.com> NNTP-Posting-Host: photon.epita.fr Function: KrAzY k0dEr X-newsreader: XRN SunLight