On Sat, May 20, 2000 at 11:14:04AM +0200, Ralf Baechle wrote:
% 
% In some C environments it's actually legal for main() to return without
% a value; there the C compiler will threat this as equivalent to return 0;.
% This is not true for gcc on Linux, there main() will return a random
% value.

IANAL, but I don't think there is ever a situation in which it is "legal"
for main to return without a value, since the ANSI/ISO standard states
that main returns int.  The standard does not say *which* int is returned,
but compliant compilers are required to return *some* int.  I would think
that, in the environments you mention, that what main returns is up to the 
compiler builder.

% Some C compilers are fairly paranoid and will complain if you don't
% properly declare the arguments for main().

Complaining is the desirable behavior, IMHO.  I haven't a copy of the
current or the new standard (C9X) in front of me, but I have never
quite understood why ANSI/ISO C says that main returns int but does
not require the compiler to issue a diagnostic if you declare it 
as returning, say, void.
 
% Just a few notes by somebody who has been dealing with portability
% problems again and again.

Regards,

Kurt

Reply via email to