Syntax for literal "s on Windows command line

J

John F

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

Mike Wahler

John F said:
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
 
M

Michael Mair

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


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

Michael Mair

Shastri said:
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
 
K

Keith Thompson

John F said:
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.
 
J

John F

: 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.
 
C

CBFalconer

Keith said:
.... 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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top