[Interest] Putting a define with spaces in the .pro file?

Murphy, Sean smurphy at walbro.com
Fri Nov 13 23:26:40 CET 2015


> Our .pro files have things like this:
>  DESTDIR = $$quote(../IgorPhoenixFolder)
> 
> Does that provide any traction?

That gets closer. After a bit of playing around, putting this in the .pro file
  DEFINES += MY_STRING=$$quote(\"\\\"Hello You\\\"\")
Which results in this for the compile arguments:
  -DMY_STRING="\"Hello You\""
Which then seems to result in the equivalent of this in the code
  #define MY_STRING "\"Hello You\""

Because the following code prints "Hello You" on the command line - including the quotes. However I was trying to get it to just print Hello You (with no quotes).

#include <QCoreApplication>
#include <QString>
#include <QDebug>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    qDebug() << QString(MY_STRING);

    return a.exec();
}

So far I haven't found a combination that works, but at this point it's really just an academic exercise to see if it's even possible. In my real application, I just added all the string defines I need to a .h file, which has advantages in only having to recompile the files that include that .h instead of having to rebuild the whole project since making changes in a .pro doesn't trigger a need for a rebuild.

Sean



More information about the Interest mailing list