Syntax for literal "s on Windows command line

Discussion in 'C Programming' started by John F, Feb 1, 2006.

  1. John F

    John F Guest

    Not exactly a C question (sorry), but I couldn't
    find a ng that seems more suitable...

    On the Unix shell command line I can successfully write
    cc -DPATH=\"abcd/\" program.c -o program
    to compile program as if it contained the line
    #define PATH "abcd/"

    But using the free MinGW http://www.mingw.org Windows
    C compiler, then
    gcc -DPATH=\"abcd\\\" program.c -o program
    fails when written from a DOS Command Prompt window.
    It kind of looks like the open quote hasn't closed
    and the command line interpreter is waiting for the
    command to be completed. I tried various and sundry
    permutations like "\"abcd\\\"" and ""abcd\\"" and
    \\\"abcd\\\\\", etc, but nothing I tried seems to work.
    (The program compiles and runs fine without that switch,
    using the default PATH.) What's the correct way to
    write this? Thanks.
    --
    John Forkosh ( mailto: where j=john and f=forkosh )
     
    John F, Feb 1, 2006
    #1
    1. Advertising

  2. John F

    Mike Wahler Guest

    "John F" <> wrote in message
    news:drqpmo$nn0$...
    > Not exactly a C question (sorry), but I couldn't
    > find a ng that seems more suitable...


    Then imo you didn't look very hard. :)

    >
    > On the Unix shell command line I can successfully write
    > cc -DPATH=\"abcd/\" program.c -o program
    > to compile program as if it contained the line
    > #define PATH "abcd/"
    >
    > But using the free MinGW http://www.mingw.org Windows
    > C compiler, then
    > gcc -DPATH=\"abcd\\\" program.c -o program
    > fails when written from a DOS Command Prompt window.
    > It kind of looks like the open quote hasn't closed
    > and the command line interpreter is waiting for the
    > command to be completed. I tried various and sundry
    > permutations like "\"abcd\\\"" and ""abcd\\"" and
    > \\\"abcd\\\\\", etc, but nothing I tried seems to work.
    > (The program compiles and runs fine without that switch,
    > using the default PATH.) What's the correct way to
    > write this? Thanks.


    <OT>
    Unix and Windows interpret the '/' and '\' characters differently.
    E.g. in Windows command line, '\' is treated as part of
    a 'path', and a double-quote character is not a valid character
    in a folder or file name. In order to learn how to use the gcc
    implementation for Windows, you'll need to study its documentation.
    </OT>

    For additional assistance, I suggest you do some or all of the
    following: visit a gcc newsgroup, gcc web site, or subscribe
    to a gcc mailing list. Google should be able to find them
    easily.

    -Mike
     
    Mike Wahler, Feb 1, 2006
    #2
    1. Advertising

  3. John F

    Shastri Guest

    use the gcc -I or -L option to include that particular lib in path
     
    Shastri, Feb 1, 2006
    #3
  4. John F

    Michael Mair Guest

    Mike Wahler wrote:
    > "John F" <> wrote in message
    > news:drqpmo$nn0$...
    >
    >>Not exactly a C question (sorry), but I couldn't
    >>find a ng that seems more suitable...

    >
    > Then imo you didn't look very hard. :)
    >
    >>On the Unix shell command line I can successfully write
    >> cc -DPATH=\"abcd/\" program.c -o program
    >>to compile program as if it contained the line
    >> #define PATH "abcd/"
    >>
    >>But using the free MinGW http://www.mingw.org Windows
    >>C compiler, then
    >> gcc -DPATH=\"abcd\\\" program.c -o program
    >>fails when written from a DOS Command Prompt window.
    >>It kind of looks like the open quote hasn't closed
    >>and the command line interpreter is waiting for the
    >>command to be completed. I tried various and sundry
    >>permutations like "\"abcd\\\"" and ""abcd\\"" and
    >>\\\"abcd\\\\\", etc, but nothing I tried seems to work.
    >>(The program compiles and runs fine without that switch,
    >>using the default PATH.) What's the correct way to
    >>write this? Thanks.

    >
    > <OT>
    > Unix and Windows interpret the '/' and '\' characters differently.
    > E.g. in Windows command line, '\' is treated as part of
    > a 'path', and a double-quote character is not a valid character
    > in a folder or file name. In order to learn how to use the gcc
    > implementation for Windows, you'll need to study its documentation.
    > </OT>
    >
    > For additional assistance, I suggest you do some or all of the
    > following: visit a gcc newsgroup, gcc web site, or subscribe
    > to a gcc mailing list. Google should be able to find them
    > easily.


    One (OT) remark:
    "abcd/"
    also works with Windows and is the canonic form
    you _should_ use.
    Coding standards like MISRA even demand that.


    Cheers
    Michael
    --
    E-Mail: Mine is an /at/ gmx /dot/ de address.
     
    Michael Mair, Feb 1, 2006
    #4
  5. John F

    Michael Mair Guest

    Shastri wrote:
    > use the gcc -I or -L option to include that particular lib in path


    Please provide sufficient context.
    This is off-topic advice which may or may not be good.
    Please refer the OP to a better NG, e.g. gnu.gcc.help
    or give your advice and crosspost with f'up set appropriately.

    There are scenarios where the OP's version may be needed, for
    example to disambiguate between headers of equal name.

    Cheers
    Michael
    --
    E-Mail: Mine is an /at/ gmx /dot/ de address.
     
    Michael Mair, Feb 1, 2006
    #5
  6. John F <> writes:
    > Not exactly a C question (sorry), but I couldn't
    > find a ng that seems more suitable...
    >
    > On the Unix shell command line I can successfully write
    > cc -DPATH=\"abcd/\" program.c -o program
    > to compile program as if it contained the line
    > #define PATH "abcd/"
    >
    > But using the free MinGW http://www.mingw.org Windows
    > C compiler, then
    > gcc -DPATH=\"abcd\\\" program.c -o program
    > fails when written from a DOS Command Prompt window.

    [...]

    You couldn't find a newsgroup that discusses MS-DOS or Windows? I see
    16 newsgroups with "msdos" in their names, and 76 with "ms-windows" in
    their names.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Feb 1, 2006
    #6
  7. John F

    John F Guest

    Michael Mair <> wrote:
    : Shastri wrote:
    : > use the gcc -I or -L option to include that particular lib in path

    : Please provide sufficient context.
    : There are scenarios where the OP's version may be needed, for
    : example to disambiguate between headers of equal name.
    Yes, my problem doesn't involve library or include paths.
    I'm trying to -D define a string that specifies a path
    where the program will cache its results when it runs.
    See http://www.forkosh.dreamhost.com/phpBB2/viewtopic.php?t=48
    for the actual problem, asked by a user of my gpl'ed program
    (skip the top two posts which deal with a different problem)

    : This is off-topic advice which may or may not be good.
    : Please refer the OP to a better NG, e.g. gnu.gcc.help
    Thanks, I'll re-post to this group.

    : Michael E-Mail: Mine is an /at/ gmx /dot/ de address.
    --
    John Forkosh ( mailto: where j=john and f=forkosh )
     
    John F, Feb 1, 2006
    #7
  8. John F

    CBFalconer Guest

    Keith Thompson wrote:
    > John F <> writes:
    >
    >> Not exactly a C question (sorry), but I couldn't
    >> find a ng that seems more suitable...
    >>

    .... snip ...
    >
    > You couldn't find a newsgroup that discusses MS-DOS or Windows?
    > I see 16 newsgroups with "msdos" in their names, and 76 with
    > "ms-windows" in their names.


    I find 59 and 173 respectively on my server! :)

    --
    "The power of the Executive to cast a man into prison without
    formulating any charge known to the law, and particularly to
    deny him the judgement of his peers, is in the highest degree
    odious and is the foundation of all totalitarian government
    whether Nazi or Communist." -- W. Churchill, Nov 21, 1943
     
    CBFalconer, Feb 2, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Leitgeb
    Replies:
    0
    Views:
    463
    Andreas Leitgeb
    May 15, 2009
  2. Mark Space
    Replies:
    0
    Views:
    492
    Mark Space
    May 15, 2009
  3. Lew
    Replies:
    0
    Views:
    957
  4. Joshua Cranmer
    Replies:
    0
    Views:
    470
    Joshua Cranmer
    May 15, 2009
  5. Anonieko Ramos

    What's wrong with rpc-literal? Why use doc-literal?

    Anonieko Ramos, Sep 27, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    391
    Anonieko Ramos
    Sep 27, 2004
Loading...

Share This Page