error C2001: Newline character in constant

Scenes

        Modify the code introduced by a colleague, add Chinese log printing, compilation error:

error C2001: Newline character in constant
fatal error C1057: Unexpected end of file encountered during macro expansion

The error points to the log printing code line of Chinese output, and the problem can be solved by commenting it out

solution

            By analyzing this problem, the encoding format of the source code file is inconsistent with other source code file encoding formats. The current source code file is Unicode, and other compiled source code files are Simplified Chinese GB2312 encoding. Click on the file, select the advanced save option, in the pop-up window, select Simplified Chinese as the encoding, save and exit.


Remarks

Visual Studio provides the "advanced save options" function, which can specify the encoding specifications of a specific code file and the line break used at the end of the line. In Visual Studio 2017, this command is not displayed in the "File" menu by default. The user needs to manually set to display this command.

  The operation method is as follows:

(1) Click the "Tools" ---> "Customize" command, and the "Customize" dialog box will pop up.
(2) Click the "Command" tab to enter the "Command" tab.
(3) In the "Menu Bar" drop-down list, select the "File" option.
(4) Click the "Add Command" button to pop up the "Add Command" dialog box.
(5) In the "Category" list, select the "File" option; in the "Command" list, select the "Advanced saving options" option.
(6) Click the "OK" button to close the "Add Command" dialog box.
(7) Select the "Advanced Save Options" option in the "Controls" list, and click the "Move Up" or "Move Down" button to adjust the position of the command.
(8) Click the "Close" button to complete the adding operation of the "Advanced Save Options" command.


Guess you like

Origin blog.51cto.com/fengyuzaitu/2554821