Re: [Dev-C++] Error using void main (void)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: Per W. <pw...@ia...> - 2005-04-21 16:50:15
|
Note that main() is ONLY allowed for C programs, where a symbol without a declared data type defaults to int, i.e. main() in reality means: int main() in a C program. For C++ programs, you MUST actually use int main() since the ISO C++ standard requires it. Yes, I know that g++ do accept the lazy form and only emits "warning: ISO C++ forbids declaration of `main=B4 with no type" if warnings are enabled. However, don't assume something about how other compilers look at ISO compliance requirements! /Per W On Thu, 21 Apr 2005, Austin Scholze wrote: > also, I have found in dev-C++ that you may just use > > main() > > without actually initializing it and that it will exit at the end of the = function. > ----- Original Message ----- > From: Verne H. Bohlender > To: Dev C++ ; Alfred P. Reaud > Sent: Wednesday, April 20, 2005 9:48 PM > Subject: Re: [Dev-C++] Error using void main (void) > > > That's what it should say as it really should be > > int main() or with all the other goodies inside the brackets. If you r= ead across it says"int main void for the two ( )'s for the void here! > > Verne > The GRIN Genius who knows nothing! > > Warnings are mostly ignorable, or nice if you like to write clean por= table code. main should always return an int as that's the exit value that= the executable gives to DOS/Win/Linux upon completion. Source should comp= ile and run with a void main. However, main's exit value will then always = be 0 and therefore useless to test for a certain execution completion statu= s. > > Alexsandro Meireles <mei...@gm...> wrote: > Hi, all! > > I tried to use the following expression in Dev-C++ > > void main (void) > > The compiler give a warning message "output of main is not int". So= mething like that. Although it gives this warning it compilies well. Why th= is happens? Main should always have a return type? > > Tks in advance! > > -- > Alexsandro Meireles > > > > Alfred P. Reaud > > |