代码UTF-8文件头格式问题

123 阅读1分钟

 Error 1 stray ‘\357’ in program
Error 2 stray ‘\273’ in program
Error 3 stray ‘\277’ in program

.cpp:1: error: stray ‘\357’ in program

.cpp:1: error: stray ‘\273’ in program

.cpp:1: error: stray ‘\277’ in program

去掉方法:参考VIM去掉utf-8 bom头

vim main.cpp

按SHIFT加分号键

:set nobomb

在以上操作的前后可通过如下查询验证

:set bomb?

如果有中文导致VC编译问题,也不要使用bom头,而是去消除中文件字串的引用问题。