Why does this name give VS running the function in a console application?
For non-Unicode programs, the standard-conforming name
main and the parameter list
int argc, char* argv .
For Unicode programs, the MSVC parameter list looks like
int argc, wchar_t* argv , and to avoid conflicts with sources and compilers that conform to the standard, the function is called
For programs that can compile in both Unicode and non-Unicode mode, the argument list looks like
int argc, _TCHAR* argv , where
_TCHAR defined as
wchar_t depending on the value of
_UNICODE . So a third name is needed for the function. This is how the name
_tmain was coined.
All this, of course, requires some magic of the linker, which must be able to determine the entry point not only in the
main function, as by the standard, but also in the
If you are sure that you do not need a Unicode application, you can rename the function to
main and give it an argument list
int argc, char* argv to conform to the standard. Or if you firmly decided that your program will run only under the WinNT / XP / 7 line (and not Win95 / 98), you can choose the Unicode version and rename the function to
wmain (accordingly, the arguments must be
int argc, wchar_t* argv ).
Belated clarification (thanks @alexolut): According to the documentation ,
_tmain is defined in
<tchar.h> with a
wmain , so your program will still have either
(And yes, you can omit parameters, or add a third
envp parameter, or declare a
void return type.)