Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!apple!bbn.com!saustin From: saustin@bbn.com (Steve Austin) Newsgroups: comp.lang.c++ Subject: Re: Can you prototype main() ????? Message-ID: <59517@bbn.BBN.COM> Date: 16 Sep 90 21:26:48 GMT References: <14227.26dc5b2f@max.u.washington.edu> <24447@uflorida.cis.ufl.EDU> Sender: news@bbn.com Lines: 28 bp@swamp.cis.ufl.edu (Brian Pane) writes: >|> I tried to compile one of his example programs with Turbo C++ I got a >|> "cannot overload 'main'" error message. It seems the compiler choked on >|> the author prototyping main (with the line: int main(); >|> Is this a problem with Turbo C++, or is it not allowed in C++ and the >|> compiler that the author used just accepted it ? It works fine in Turbo >|> if I remove the prototype. >|> > >Actually, main is "int main (int, char**)." If you declare main without >argc or argv, the compiler realizes that you must be talking about some >*other* main. Perhaps the author was using a machine without an operating >system? :-) I don't think it make much sense at all to prototype main. You prototype a function in order to call it - I don't know what you would get if you tried to call main, but I bet it wouldn't be good. Also, if you do manage to prototye main, you will be asking for its name to be mangled, which will not please your linker. Other things wrong with the above definition "int main(int, char **)" are that main does not return a value (again, I'm not sure what would happen if you tried to return someting from main, but I bet it wouldn't be very meaningful). Also, main can have a third argument (at least on some systems) which is a "char **" and conatins the environment. Steve Austin