delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2015/11/26/15:08:45

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:content-type
:content-transfer-encoding:mime-version; q=dns; s=default; b=Goc
TyZ6bWa+XsyMt8hCbZ8pOCKLjFap05hnjcPfeyaIdwbLAbfMx8aPtllxd7m0YvUZ
1/ELFbiQwh6J61iMdxvLunw+zMosT3++xRNIte3xVqAi70LpcMF/a+lqJKMDMHON
tZnszcEEqGdG9Uzr8TEw7AWlXiLJ8v/+LRrKojPU=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:content-type
:content-transfer-encoding:mime-version; s=default; bh=evxYDGaP5
ZFS41QeY4wM7eo+sow=; b=C/0mJ1e4pzYm/oKZlIMht93fT/vSQCOHBq3BNBk5Y
iZ9qI7gfrKDXOL5gYbWZOE6l80uiD7EH7LXW6ym/w/JgYODUss1DjzoIqCRVromi
e240pac/cGkh+awEY6o9ReZ5QyzC3N+jT5/DxGvQZGsSZxyToCHlgJ/WokEpa0Sm
VY=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=2.1 required=5.0 tests=AWL,BAYES_50,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mailuogwhop.emc.com
X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd02.lss.emc.com tAQK8QOZ016013
X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd02.lss.emc.com tAQK8QOZ016013
From: "Gluszczak, Glenn" <glenn DOT gluszczak AT emc DOT com>
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: Argument parsing with gcc compiled program
Date: Thu, 26 Nov 2015 20:08:12 +0000
Message-ID: <91DCAC3CB99C724EB365BB64677FBE7B01DD4B@MX204CL04.corp.emc.com>
MIME-Version: 1.0
X-Sentrion-Hostname: mailusrhubprd52.lss.emc.com
X-RSA-Classifications: Source Code, public
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id tAQK8gDW027441

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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019