Дана уторак 12 јун 2007, Alexander Neundorf је написао(ла):
> On Tuesday 12 June 2007 12:38, Welter Luigi Silva wrote:
> > Hi again,
> > I'm trying to have a definition with a string value, say, "foo".
> > However, when I tried the following command:
> >
> > add_definitions(-DFOO="foo")
> >
> > and used FOO in my source file -- in a command like printf("%s\n", FOO)
> > -- I got 'foo' without the quotes, which is not a valid string literal,
> > as I wished it was.
> > I've also tried the command bellow but it did not work as well:
> > add_definitions(-DFOO="\"foo\"")
>
> You need more escaping, the following should work:
> add_definitions(-DFOO=\\"foo\\")
Yes, and for increased readability, I would suggest you to use:
add_definitions(-DFOO="\\"foo\\"")
so that you get
gcc -DFOO="\"foo\"" yourfile.c
when CMake compiles your file and, obviously, FOO="foo" in C.
On the sidenote, how does that relate to various shells? I'm using bash, but
did anybody cases with escapes like this one in other shells such as csh,
zsh, {,d}ash, or Micro$oft's favourite - ksh?
Filip
--
Filip Brcic <[EMAIL PROTECTED]>
WWWeb: http://purl.org/NET/brcha/home/
Jabber: [EMAIL PROTECTED]
Jabber: [EMAIL PROTECTED]
Jabber: [EMAIL PROTECTED]
ICQ# 40994923
Yahoo! brcha
MSN: [EMAIL PROTECTED]
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake