There are two main causes:
1. The Program (*. C, *. h) uses Chinese Punctuation Marks (full angle), such as;,}, +.
Change it to the punctuation marks in English.
Sometimes, a similar error occurs when a space is deleted and entered again.
It is quite easy to replace it in vim.
How can I see the error message?
Od-C hello. c> log.txt
You can see the symbol in the log.
2.
If an error occurs when an English Punctuation Mark is replaced, the file storage format is incorrect.
Generally in Windows files are stored in ANSI format, in order to be universal in Linux, it is recommended to save as a UTF-8 without BOM
Encoding format, because GCC and G ++ currently do not support BOM encoding format for UTF-8.
What should I do if I encounter a UTF-8 BOM error when compiling with G ++?
$ G ++-I.../../include unit_test.cpp-O unit_test
Unit_test.cpp: 1: Error: The program has a free '\ 357'
Unit_test.cpp: 1: Error: The program has a free '\ 273'
Unit_test.cpp: 1: Error: The program has a free '\ 277'
In file encoded ded from unit_test.cpp: 63:
...
Or in the English system:
$ G ++-I.../../include unit_test.cpp-O unit_test
Unit_test.cpp: 1: Error: stray '\ 357' in program
Unit_test.cpp: 1: Error: stray '\ 273' in program
Unit_test.cpp: 1: Error: stray '\ 277' in program
In file encoded ded from unit_test.cpp: 63:
...
How do I determine if a file is stored using a UTF-8 Bom?
Run the following command:
$ Cat CPP/src/unit_test/unit_test.cpp | HD-N 10
00000000 ef bb bf 2f 2a 2a 2a 2a 2a |.../****** |
0000000a