本文介绍了“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":为什么会发生这种情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 18:25