visual-studio - Visual Studio不允许我使用某些变量名

标签 visual-studio visual-c++ syntax-error

我正在使用Visual Studio 2010 Express。当我使用某些变量名时,例如“near,“far”,“IN”,“OUT”),我无法编译:在使用的变量名之后出现语法错误。
例子:

z = 1.0/(far - near);

错误:
error C2059: syntax error : ')'

如何禁用此“功能”?

最佳答案

farnear是16位时代的内置编译器关键字。它们不再存在,不再具有任何意义,但是出于向后兼容的原因,它们仍被定义为Windows header 中的宏。

如果您不想要它们,只需取消定义它们(或不包括Windows header )即可:

#undef far
#undef near

关于visual-studio - Visual Studio不允许我使用某些变量名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8948493/

相关文章:

c# - 在 Visual Studio 2008 for .NET CF 中处理不同的分辨率

c++ - `if ( __some_bool__ != NULL )` 的行为如何?

python - python : cannot instantiate more than one or two variables (SyntaxError raised)

c++ - Visual Studio 中 C++ 代码的变量依赖关系图

visual-studio - 是否可以在 Visual Studio 2008 中编译 .NET 1.1?

visual-studio - 如何在 visual studio 中为自定义库项目生成多部分程序集(每个文件夹),C#?

C++ - 传递给线程的数据应该是易变的吗?

visual-c++ - 使用带有/MT 标志的 MSVC 编译 jrtplib

mysql - 创建触发器以使用另一个表的更改来更新表

函数中的 Postgresql 公共(public)表达式表 (CTE)