void main()

Charles Hannum CMH117 at PSUVM.BITNET
Sat Nov 18 03:37:06 AEST 1989


The basic problem is that you ass/u/me that the compiler will always return
values in a register.  If this is the case, then fine.  But it is emphatically
**NOT** the case.  Making such gross assumptions about the way any particular
compiler works is just begging for trouble.  C was never defined to return
values on the stack.  The way this is done may vary from compiler to compiler,
and to ass/u/me it does it one particular way makes your code non-portable.

If all you want to do is disable the warning, just add a return(0) at the end
of your main() function.  Even if it isn't optimized out, it will only take
a couple of bytes.  This is a much better alternative than declaring main()
as a void.

--
- Charles Martin Hannum II       "Klein bottle for sale ... inquire within."
    (and PROUD OF IT!!!)         "To life immortal!"
  c9h at psuecl.psu.edu             "No noozzzz izzz netzzzsnoozzzzz..."
  cmh117 at psuvm.psu.edu           "Mem'ry, all alone in the moonlight ..."



More information about the Comp.lang.c mailing list