Note that the premise is that the project has been compiled under MinGW . This article does not solve the problems existing in the qt project itself, but only provides several possible useful problems caused by replacing the compiler.
Error: error: C2001: There is a newline character in the constant
Solution
- Add the following code in the .pro file (I added it between CONFIG and SOURCES to be useful, but the specific location may not be unique, you can try it yourself, it is useful)
msvc {
QMAKE_CFLAGS += /utf-8
QMAKE_CXXFLAGS += /utf-8
}
- Add the following code in the .pro file
QMAKE_CXXFLAGS += /source-charset:utf-8
QMAKE_CXXFLAGS += /execution-charset:utf-8
- Modify the newline format in the upper right corner of QtCreator, change Windows (CRLF) to Unix (LF)