Code UTF8 Road 2: Resolving C1071 Error in VS Compilation

Following the last time I resolved the C4819 warning ( click here to open ), I ran into an encoding issue after continuing.

First of all, there is an error in the compilation of a file, indicating that the variable is not defined, but after the file is changed to GBK encoding, the compilation is correct. Finally, through the line-by-line exclusion method, it is found that adding a newline after a line comment can be compiled correctly, ignore it for the time being ;

Then, I encountered this C1071 error again, prompting "an unexpected end of file was encountered in the comment", you can confirm that the code is no problem, and there is no problem compiling before changing to UTF8 encoding (using GBK encoding), find it online Confirm that it is still a coding problem, and the compilation options in VS2015 can support the character set of the specified source code, so as in the previous article, add specific compilation options to the QT project file to solve this problem.

# set source charset
QMAKE_CXXFLAGS += -source-charset:utf-8

This option can also be written to specify both the source code character set and the execution character set not UTF-8.

# set source charset and execution charset
QMAKE_CXXFLAGS += -utf-8

Note: write += here instead of directly equaling, otherwise other original options will be overwritten.

Reference:  https://msdn.microsoft.com/en-us/library/mt708819.aspx

            https://msdn.microsoft.com/en-us/library/mt708821.aspx

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325771534&siteId=291194637
Recommended