This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: about main must return "int"
- From: David Odin <David at dindinx dot org>
- To: Amy Lin <alin at itsc dot uah dot edu>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 7 Jul 2003 22:12:11 +0200
- Subject: Re: about main must return "int"
- References: <3F09CFAD.8020009@itsc.uah.edu>
On Mon, Jul 07, 2003 at 02:53:17PM -0500, Amy Lin wrote:
> Hi, I am new with this list, and I need your help.
>
> After installing Redhat 8.0 which has gcc 3.2, I ran into a problem when
> recompiling a project. with c++. It errors out on "main" must return
> "int". All my old codes with "void" main. I used c++ from egcs-1.1-2
> (redhat 7.3) and it was no problem there. My question is: Is this a bug
> of gcc 3.2, or this is a permanent change and I will have to change my
> codes?
>
In C and C++, the main() function _has_ to return an int, which will
be used by the shell which run the program. However, with C++, the
return statement isn't mandatory anymore, and a main() function with a
missing return statement will silently return 0.
HTH,
DindinX
--
david@dindinx.org
main(a,b){for(;a=223&getchar()+1;putchar(32))if(a>64&a<92)for(b=0,a=
"Xzjtpnd~xFTvHhDfRl|P\\^LZJr"[a-66];(a/=2)>1;b+=a%2)b&&putchar(45+a%2);}