This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Argument parsing with gcc compiled program




On 26/11/2015 21:08, Gluszczak, Glenn wrote:
For some reason when I compile a C program in gcc, double backslashes within quotes are stripped.
But if I compile with Visual Studio this does not happen.  I used a small
test program to demonstrate.

VS
c:\msvc2010_SP1\VC>a.exe -s something "something d\:\\hello"

Command-line arguments:
   argv[0]   a.exe
   argv[1]   -s
   argv[2]   something
   argv[3]   something d\:\\hello
CL: a.exe  -s something "something d\:\\hello"


GCC
$ ./a.exe -s something "something d\:\\hello"

Command-line arguments:
   argv[0]   ./a
   argv[1]   -s
   argv[2]   something
   argv[3]   something d\:\hello
CL: K:\sat-misc\src\sat-main\sat\src\wiz\a -s something "something d\:\hello"

Is there some compiler option or setting I'm unaware of?
Thanks,
Glenn


bash is stripping the double backslashes
when using " , try '

$ ./a.exe -s something 'something d\:\\hello'

Command-line arguments:
  argv[0]   ./a
  argv[1]   -s
  argv[2]   something
  argv[3]   something d\:\\hello
CL: "E:\cygwin64\tmp\a.exe"




--
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]