While writing some small code for open-source, I have encountered a behavior difference when compiling using G++ and MSBuild (VS compiler). I am wondering whether this is something that is injected into the executable by the compiler or is this a Windows property set to the executable. In either case, I'd like to turn it off... (is there a flag in g++?).
The problem: When I pass an asterisk("*") as a parameter to the executable that was compiled in Visual Studio, argv contains an asterisk (argc==2, argv[1]=="*"), while doing the same thing using a code that is compiled with G++, the asterisk is converted into a file list (argc==7, argv[1]=="first file in folder", argv[1]=="second file in folder", ...).
I am working on Windows 10, compiling with VS 2019 and G++ 10.2.0 (MinGW).
You can recreate the scenario just by printing the argv content:
int main(int argc, char* argv[])
{
for (int i = 0; i < argc; i++)
{
std::cout << argv[i] << std::endl;
}
}
The call to the executable is from command-line (cmd):
a.exe *
Thanks Lior