🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Bruno RICHARD Thu, 04 Apr 1996 19:21
int main(void) or int main()?
#4984
Author: Bruno RICHARD
Date: Thu, 04 Apr 1996 19:21
13 lines
911 bytes
What is the recommended declaration for a function that does
not take arguments and does not return anything:

   void myfunc();
or
   void myfunc(void);

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, and
I am wondering whether there could be some portability problems around.

-bruno
Re: int main(void) or int main()?
#4988
Author: Frank DENIS (Jedi/Sector One)
Date: Fri, 05 Apr 1996 12:46
42 lines
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                  ._-^-_/
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads