Qt with Visual Studio macro issue

  • Hi! I want to open my Qt project in Visual Studio for more advance debugging. The problem is it not recognize one defined constant from Qt pro file.

    Qt pro file:
    DEFINES += APP_NAME=$$shell_quote(\"$$QMAKE_TARGET_NAME\")

    Works normal in Qt IDE. In Visual Studio 2015 displays error - user-defined literal operator not found (#define APP_NAME ""My App Test"").

    So how to make it compatible with Visual Studio 2015 and Qt?

  • The problem is with wrong escape, in Visual Studio it displays double quotes around My App Test (APP_NAME constant). How to escape properly? Thanks in advance.

  • How to make special characters such as char(32) work in Qt pro file? Thanks.

  • Lifetime Qt Champion


    Isn't that because you are already quoting the result before calling shell_quote ?

  • @SGaist

    Without quotes it's not working in Qt. Throws errors such as C2065: 'My': undeclared identifier and C2146: syntax error: missing ')' before identifier 'App'.

    The $$shell_quote(\"$$QMAKE_TARGET_NAME\") function works in Qt but not in Visual Studio.

  • Lifetime Qt Champion

    That's the problem with complex defines, each application and terminal might handle them differently.

    One alternative could be to generate a header file that contains that kind of contents and that you'll include in your application code.

  • @SGaist

    Thanks. It's now compatible with Qt and Visual Studio 2015.

  • Lifetime Qt Champion

    You're welcome !

    What did you implement to make it work ?

  • @SGaist

    The solution is to create C++ header file with APP_NAME constant and include it where it requires. Now it's compatible with Qt and Visual Studio 2015.

Log in to reply