Visual Studio: C++ newline constant error

Viewed 12878

Using Visual Studio on a Qt project (with the Qt addon), seems to always throw up an error message:

error C2001: newline in constant

From the following line:

this->setApplicationVersion(QString(BUILD_VERSION));

or whenever I use a compiler constant defined in my QMake file. BUILD_VERSION is defined in my QMake build recipe, compiling the project works successfully if I use a different IDE (even when I use the same MSVC compiler, everything works).

I imagine I'm either missing a preference in the Qt addon or inside Visual Studio, or I need to redefine my constant's outside of my QMake files etc...

The constant is defined and picked up by Intellisense as:

#define BUILD_VERSION \"0.1.0\"

Found the issue is down to escaping the quotes in the constant, in Visual Studio this won't work but it will work with Mingw, and the MSVC compiler on the command line. Defining constants without the escaping works with Visual Studio:

#define BUILD_VERSION "0.1.0"

The problem is to define the constants in the QMake file, I need to escape like:

#define BUILD_VERSION \\\"0.1.0\\\"

Is there a way to define them in the QMake file and keep them working with Visual Studio?

1 Answers
Related