0

We are still on Qt4.7 in our workplace, so bear in mind this could be a known bug fixed in later versions. I have googled for this problem and it is possible I am not using correct terms. Here goes.

In my .pro file I have:

win32
{
    DEFINES += LOGFILE_DIR=\\\"C:\\ProgramData\\Foo\\Logs\\\\\"
}
unix
{
    DEFINES += LOGFILE_DIR=\\\"/var/log/Foo/\\\"
}

Where "Foo" is our company name.

This builds and runs fine on Linux. When I try to build this on Windows, moc.exe chokes on any header file it parses. With "chokes" I mean; it starts the parse but never completes.

If I change the DEFINE to:

win32
{
    DEFINES += LOGFILE_DIR=\\\"C:\\ProgramData\\Foo\\Logs\\ \\\"
}

(note the added space)

Then moc.exe runs just fine, but I now end up with a space at the end of my string that I just do not want.

Are there any special characters that moc.exe would parse, but otherwise ignore?

iwarv
  • 335
  • 4
  • 13
  • Did you try to define it like: `DEFINES += LOGFILE_DIR=\\\"C:/ProgramData/Foo/Logs\\\"`? – vahancho Feb 09 '18 at 09:18
  • 1
    Couldn't you use `/` instead of double baskslash (as in Unix)? AFAIK, most tools under Windows are able to process them as well. Btw. it would improve readability/maintainabilty. – Scheff's Cat Feb 09 '18 at 09:43
  • Yep, forward slashes work just as well. I just tried. So forward slashes help me on this occasion because the framework uses it to open a QFile and Qt deals with it. But let's be honest here; this is a workaround. – iwarv Feb 09 '18 at 10:08
  • No it is not, the forward slash is the supported, platform independent format for Qt. If really needed to call external functions, one can use `QDir::toNativeSeparators()`. – SteakOverflow Feb 09 '18 at 14:21

0 Answers0