I have a new main function that I asked the linker to point to in the Visual Studio.
I can correctly execute this function. However the command line arguments that I am getting is not correct.
Currently this is my signature
int NewMain(int argc, const char* argv[])
{
cout << "New Main" << endl;
for (int i = 0; i < argc; ++i)
{
cout << argv[i] << "\n";
}
return 0;
}
However when I use the same function with the standard main, I am getting all the arguments.
When you specify an entry point to the linker, the function that gets called is not passed any arguments. Its signature is int entrypoint(void);
If you want the command line, you can retrieve it with GetCommandLine
. If you want to parse that into arguments, you can either do so on your own, or use CommandLineToArgvW
-- but note that this is only available in a wide-character version, so if you want a standard command line (using char
s, not wchar_t
s) you have to do that on your own.
A community addon from msdn:
Custom Entry Point Function with Command Line Arguments
It is not possible to specify a custom entry point with command line arguments since when you specify such an entry point mainCRTStartup is no longer called and thereby does not provide the entry point with the command line arguments such as int argc and char* argv[].
http://msdn.microsoft.com/en-us/library/f9t8842e%28v=vs.80%29.aspx