Mail Archives: djgpp/1996/07/09/01:29:38
Reply to message 0675956 from CSRABAK AT DCE03 on 07/08/96 6:03PM
>>BTW, just using 'main()' as your definition is not very good either. While
it
>>is technically correct (an unstated return value defaults to int and an empty
>>argument list defaults to void), you are relying on the _compiler_ to
> ^^^^^^^^^^^^^^^^Not quite! In ISO (ANSI) for compatibility
>with existing code, it may mean anything from "void" to "any number of
>arguments". In C++ however your observation apply in full. So it is better
>(in ISO/ANSI C) to follow your own advice!
Actually, what you are referring to is not ANSI at all, but rather the
compatibility of nearly all ANSI compilers with the ambiguous function
definition methodology of traditional C. Under _pure_ ANSI, an empty
argument list indicates a void argument list. So using 'main()' is only
truly dangerous if you are writing a program which may be compiled
on a traditional compiler. In that case, however, 'int main( void )' would
fail, because 'void' is not recognized by traditional C. As long as you
stay within ANSI, empty argument lists are not actually dangerous, just
bad programming.
John
- Raw text -