quot;error: stray #39;XXX#39; in C++ programquot;: Why does this happen?(“error:stray XXX in C++ program:为什么会发生这种情况?)
问题描述
我正在用 C++ 编写一个小程序,遇到一个奇怪的错误:
I'm writing a little program in C++, and come across a strange error:
src/Makefile/Tool.cpp:42:3: error: stray ‘302’ in program
src/Makefile/Tool.cpp:42:3: error: stray ‘240’ in program
我正在用 Vim 编写这个程序,对应的行(显示隐藏字符)是:
I'm writing this program in Vim and the corresponding line (showing hidden characters) is:
>--->---std::vector<std::string> { "--debug" }$
这个问题不是关于解决这个错误,因为我只需要复制回该行,错误原因就会消失.
This question is not about resolving this error, as I just have to copy back the line and the error-cause disappear.
好像是一些字符在激活所有相关选项后被 Vim 隐藏了导致的错误!
It seems that the error is caused by some characters even hidden by Vim after activating all relative options!
问题是可能导致这些错误的原因.
The question is about what could have caused those errors.
推荐答案
"302240"
是 U+00A0 NO-BREAK SPACE
的 UTF-8.Vim 通常不会将其突出显示为任何特殊的东西,因此即使您启用了 'list'
模式,也有可能有人偷偷溜进来.
"302240"
is UTF-8 for U+00A0 NO-BREAK SPACE
. Vim won’t normally highlight it as anything special, so it’s possible for one to sneak in even if you have 'list'
mode enabled.
您可以通过以下方式突出显示它们:
You can highlight them with:
:set listchars+=nbsp:.
或者任何你喜欢的角色.
or any character you like.
这篇关于“error:stray 'XXX' in C++ program":为什么会发生这种情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“error:stray 'XXX' in C++ program":为什么会发生这种情况?


基础教程推荐
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 这个宏可以转换成函数吗? 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 常量变量在标题中不起作用 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 我有静态或动态 boost 库吗? 2021-01-01