Hello, In short, I have a problem with passing "\\127.0.0.127\foo.cxx" argument to a called program:
- if the executed program is compiled with cygwin's gcc the program receives \127.0.0.127\foo.cxx (just one backslash at the begining). - if it's compiled with cl it gets \\127.0.0.127\foo.cxx (double backslash - what I expected) I suspect cygwin incorrectly mangles backslashes in this case - or maybe I'm quoting it incorrectly, or it is Windows fault? Details: I have a short program (source code for all programs attached at the end) that just prints it's argv on standard output. I compile this program twice: once with gcc from cygwin and once with VS cl. I have another small program that executes those two programs using CreateProcessA() and passes the same argument to them. Yet the programs show unexpected difference (ignoring the acceptable difference in argv[0]). Please see the log: ------------- $ cl dumpargs.c /Fedumpargs_cl.exe [...] $ gcc -Wall dumpargs.c -o dumpargs_gcc.exe $ gcc -Wall -o createprocess.exe createprocess.c $ ./createprocess.exe Command: F:\t\dumpargs_gcc.exe "\\127.0.0.127\foo.cxx" /cygdrive/f/t/dumpargs_gcc \127.0.0.127\foo.cxx Command: F:\t\dumpargs_cl.exe "\\127.0.0.127\foo.cxx" F:\t\dumpargs_cl.exe \\127.0.0.127\foo.cxx ------------- As you can see dumpargs_gcc receives "\127.0.0.127\foo.cxx" and dumpargs_cl receives "\\127.0.0.127\foo.cxx". In my opinion, based on "Parsing C++ Command-Line Arguments" (http://msdn.microsoft.com/en-us/library/17w5ykft%28VS.100%29.aspx), the cl version is correct. Could you please explain if this is cygwin/microsoft or my bug? Below I'm pasting source code for the createprocess and dumpargs program: --- cut --- dumpargs.c --- cut --- #include <stdio.h> int main(int argc, char **argv) { int i; for (i = 0; i < argc; ++i) { printf("%s\n", argv[i]); } return 0; } --- cut --- cut --- cut --- --- cut --- createprocess.c --- cut --- #include <windows.h> #include <stdio.h> void runCommand(char * command) { STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&pi, sizeof(pi)); ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); printf("\nCommand: %s\n", command); CreateProcessA(NULL, command, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi); WaitForSingleObject(pi.hProcess, INFINITE); CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); } #define COMMAND_ARGS " \"\\\\127.0.0.127\\foo.cxx\" " int main() { runCommand("F:\\t\\dumpargs_gcc.exe " COMMAND_ARGS); runCommand("F:\\t\\dumpargs_cl.exe " COMMAND_ARGS); return 0; } -------------------------------------------- -- Piotr Krukowiecki -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple