...
.... listed all the C and
C++ compilers that used void main() in BOTH C and C++. In fact, if you could
learn to click on the link they gave to Microsoft, you would see where
Microsofts online documenation for their C++ compiler uses void main().
Yes, but the problem is that you have to also define the
context of such uses, as I clearly explained in another message.
For instance, with Comeau C++, if I have:
//voidmain.cpp, this is supposed to be Standard C++ code
void main()
{
}
and compile it in non-strict mode, then it compiles with
a warning, which can be turned off, both of which is allowed.
E:\tmp>como voidmain.cpp
Comeau C/C++ 4.3.3 (Sep 23 2003 11:25:46) for _MS_WINDOWS_x86_Beta9
Copyright 1988-2003 Comeau Computing. All rights reserved.
MODE:non-strict warnings microsoft C++
"voidmain.cpp", line 1: warning: return type of function "main" must be "int"
void main()
^
However, if I compile it in Comeau strict mode, then it gives:
E:\tmp>como --A voidmain.cpp
Comeau C/C++ 4.3.3 (Sep 23 2003 11:25:46) for _MS_WINDOWS_x86_Beta9
Copyright 1988-2003 Comeau Computing. All rights reserved.
MODE:strict errors C++
"voidmain.cpp", line 1: error: return type of function "main" must be "int"
void main()
^
1 error detected in the compilation of "voidmain.cpp".
Similarly, if I compiler with VC++ in non-strict mode:
E:\tmp>cl voidmain.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
voidmain.cpp
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.
/out:voidmain.exe
voidmain.obj
However, if I compile it in strict C++ mode, it gives:
E:\tmp>cl /Za voidmain.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
voidmain.cpp
voidmain.cpp(2) : warning C4326: return type of 'main' should be 'int' instead o
f 'void'
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.
/out:voidmain.exe
voidmain.obj
which, although it is labelled "warning" actually meets the
requirements of Standard C++ regarding diagnostics.
Note as well that some standards allow for invalid input
to still render to an executable. That moves into something
else though.
So to say that a vendor allows something or other really
needs to be put into context. So, when you point out that
say MS documentation uses void main(), and I'm sure it does,
since I've seen it, you're referring to their non-strict mode.