QtCreator converts the project compiled by MinGW to MSVC and reports an error

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

  1. 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
} 
  1. Add the following code in the .pro file
QMAKE_CXXFLAGS += /source-charset:utf-8
QMAKE_CXXFLAGS += /execution-charset:utf-8
  1. Modify the newline format in the upper right corner of QtCreator, change Windows (CRLF) to Unix (LF)
    insert image description here

Guess you like

Origin blog.csdn.net/qq_43570115/article/details/128488531