Qt with Visual Studio macro issue
-
wrote on 24 Feb 2017, 14:51 last edited by Cobra91151
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.
Code:
Qt pro file:
QMAKE_TARGET_NAME = My App Test
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?
-
wrote on 24 Feb 2017, 19:24 last edited by Cobra91151
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.
-
wrote on 25 Feb 2017, 14:11 last edited by
How to make special characters such as char(32) work in Qt pro file? Thanks.
-
Hi,
Isn't that because you are already quoting the result before calling
shell_quote
? -
wrote on 26 Feb 2017, 19:41 last edited by Cobra91151
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. -
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.
-
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.
wrote on 27 Feb 2017, 09:24 last edited byThanks. It's now compatible with Qt and Visual Studio 2015.
-
You're welcome !
What did you implement to make it work ?
-
wrote on 20 Apr 2017, 18:49 last edited by
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.