Howard said:
with all the posts I see that have "void main()", and all the resulting
corrections, I have to wonder...is there a commonly-used IDE out there that
generates "void main()" by default when creating a new project? Or is this
a practice taught in schools? Or...? (Just curious as to why it's so
common.)
Visual C++, from Microsoft's Visual Studio, creates the correct return value
for both main(), _tmain(), and all the Microsoft-specific alternatives.
However, a majority of MS's sample code, and sample code from their vassal
states, uses 'void main', just as it uses 300 line functions, redundant
typecasts, downcasts, rampant code duplication, pointers that could have
been references, etc.
This sample code's intent is to lead programmers to use MS tools in the most
sloppy and fragile way. If programmers cannot easily port code to another
compiler, then they cannot "jump ship" and reposition their offerings to
target other platforms.
This newsgroup does much work to reaffirm programmers' independence from
their vendor's sloppy sample code. But that work devolves when you read all
the screaming admonitions against 'void main'.
'void main' also appears in embedded code situations, where 'main()' might
compile into the actual startup address for a chip. A return value from such
a 'main()' cannot "go anywhere", because no software environment hosts such
a program. This is still not an excuse to write 'void main'.