Must main return a value?

SQUID 6 on the DARK side hooverm at sysjj.mdcbbs.com
Fri Jun 28 17:25:21 AEST 1991


In article <1991Jun28.043342.27540 at ptcburp.ptcbu.oz.au>, michi at ptcburp.ptcbu.oz.au (Michael Henning) writes:
> walterm at hpwrce.HP.COM (Walter Murray) writes:
> 
>>Is the following program strictly conforming?
> 
>>   int main(void) { return; }
> 
>>Many people have written that the main function must return a value.
>>I can't find such a requirement in the Standard.  I have read 2.1.2.2.3
>>and 3.6.6.4.  Am I missing something?
>
>...stuff deleted...
>
> some (non-conforming) implementations to not return a defined value
> to the OS when a return from main is executed (even if that return
> specifies a value). So it pays to write
> 
> int main(void) { exit(0); }
> 
> to be sure. Unfortunately, many versions of lint will complain about
> an undefined return value from main in this case, because they do not
> know about exit(). If you want to be paranoid, you can write
> 
> int main(void)
> {
> 	exit(0);
> 	return 0;	/* Keep lint happy */
> }

	I've run into this problem running code on 3 platforms (VMS,SUN & PC)

I use:
	void main()
	{
	insert magic code here
	}

This seems to work well on all three platforms.


			Mark  <o===6



More information about the Comp.std.c mailing list