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:
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?
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.
Isn't that because you are already quoting the result before calling
Without quotes it's not working in Qt. Throws errors such as C2065: 'My': undeclared identifier and C2146: syntax error: missing ')' before identifier 'App'.
$$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.
Thanks. It's now compatible with Qt and Visual Studio 2015.
You're welcome !
What did you implement to make it work ?
The solution is to create C++ header file with
APP_NAMEconstant and include it where it requires. Now it's compatible with Qt and Visual Studio 2015.