(* func)(fred, bert)

Mike Macgirvin mike at relgyro.stanford.edu
Wed Nov 15 09:43:23 AEST 1989


In article <11592 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>In article <812 at bbm.UUCP> darcy at druid.UUCP (D'Arcy J.M. Cain) writes:
>>In article <0175 at sheol.UUCP> throopw at sheol.UUCP (Wayne Throop) writes:
>>>> dg at lakart.UUCP (David Goodenough)
>>>> void main()
>>>It is well worth mentioning (again) that it is NOT a good idea
>>So what?  If you exit your program through some cleanup routine (perhaps
>Wayne's right and you're wrong.  In a hosted environment main() has

	OK, this thing has my head spinning. I use Microsoft 'C' with full
warnings. I do something easy like:

#include <stdio.h>
#include <process.h>
int main(void)
{
	(void) printf("Hello world\n");
	exit(0);
}

	And the darn thing complains that I'm not returning a value.
	So in order to make the compiler shut up, I have to:

#include <stdio.h>
#include <process.h>
int main(void)
{
	(void) printf("Hello world\n");
	exit(0);
	/* NOT REACHED */
	return(0);
}
	This seems like a heck of an overkill to produce 'hello.c' without
any warnings. So how do YOU 'exit' a program? Granted, in SOME implementations,
a 'return' from main places the return value in the program's exit status,
but I'm not sure that it is universal. I thought that was was 'exit' was for.
	I realize what the compiler is complaining about, but the solution
seems to be bad coding practice. (My Unix compiler will cough on the above
with a 'Statement not reached' warning...).
	Any thoughts?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+  Mike Macgirvin              Relativity Gyroscope Experiment (GP-B)    +
+  mike at relgyro.stanford.edu   (36.64.0.50)                              +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



More information about the Comp.lang.c mailing list