[Qt-interest] Mingw/GCC via QtC for windows - Defines with spaces problem(?)

Garth Dahlstrom ironstorm at gmail.com
Tue Mar 3 00:55:47 CET 2009


Rohan,
Outside double quoting from your first example works on
QtC/Make/MingW-GCC-Win32, in my case the define is win32 scope, so I'm okay
even if the escaping is different then Unix, but the I'll try second
approach if I need something portable and the first fails me.

I can't thank you enough, I was bashing my head against that one for quite a
while yesterday/today...

Cheers,

-G
              __
--- == __/ t.O ==--
http://stacktrace.org/


On Mon, Mar 2, 2009 at 6:20 PM, Rohan McGovern <rohan.mcgovern at nokia.com>wrote:

> On Tuesday 03 March 2009, ext Garth Dahlstrom wrote:
> > Hi,
>
> Hi Garth,
>
> >
> > I'm currently trying to pass an define into my application in Qt
> > Creator for Windows.  I'm hitting a problem with properly
> > escaping defines that have spaces in their payload.
> >
> > I can do this in my .pro file:
> >
> > DEFINES += SETTINGS_FILE=\\\".mixxx.cfg\\\"
> >
> > and that works.
> >
> > However  when I try every escaping combination I can think for
> > this:
> >
> > DEFINES += SETTINGS_PATH=\\\"Local Settings/Application
> > Data/Mixxx/\\\"
> >
> > I either end up with
> >
> > --> missing terminating " char
> >
> > or something mangled before it gets to gcc  (i.e.
> > -DSETTINGS_PATH=\"Local -DSettings/Application -DData/Mixxx/\" )
> >
>
> I used to do it that way until I found out that the amount of
> backslashes required is platform-specific.
>
> You can try it this way.  Leave out the quotes from the define,
> which means you'll be defining a bareword instead of a string:
>
>  DEFINES += "_SETTINGS_PATH=Local\ Settings/Application\ Data/Mixxx/"
>
> Note, the outer double quotes are to let _qmake_ know it's all
> one argument, and the backslashes before the spaces are to let
> _make_ know it's all one argument.
>
> Then stringify it in your source:
>
> #define __STRINGIFY(x) #x
> #define _STRINGIFY(x) __STRINGIFY(x)
> #define SETTINGS_PATH _STRINGIFY(_SETTINGS_PATH)
>
> I don't know if that works with all compilers.
>
> --
> Rohan McGovern
> Qt Software, Nokia
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090302/31051d14/attachment.html 


More information about the Qt-interest-old mailing list