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



Sorry I should have specified, this is not bash as this happens with the gcc compiled
program within a Command Prompt session.


K:\>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"


==============================================================


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

===============================================================================


#include <Windows.h>
#include <stdio.h>

int main( int argc, // Number of strings in array argv
 char *argv[],      // Array of command-line argument strings
 char **envp )      // Array of environment variable strings
{
    int count;
   char *gcl;

    // Display each command-line argument.
    printf("   \nCommand-line arguments:\n" );
    for( count = 0; count < argc; count++ )
        printf( "  argv[%d]   %s\n", count, argv[count] );

 
    gcl = GetCommandLine();
    printf("CL: %s\n",gcl);
}


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