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":为什么会发生这种情况?
基础教程推荐
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 从 std::cin 读取密码 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07