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: List-Subscribe: List-Archive: List-Post: List-Help: , 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" To: "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> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-Sentrion-Hostname: mailusrhubprd52.lss.emc.com X-RSA-Classifications: Source Code, public Content-Transfer-Encoding: 8bit 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 #include 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