Visual Studio不允许我使用某些变量名 [英] Visual Studio doesn't allow me to use certain variable names
问题描述
我正在使用Visual Studio 2010 Express.当我使用某些变量名时,例如"near,"far","IN","OUT"),我无法编译:在使用的变量名之后出现语法错误. 示例:
I'm using Visual Studio 2010 Express. When I use certain variable names, like "near, "far", "IN", "OUT", I can't compile: I get syntax errors located after the variable name used. Example:
z = 1.0/(far - near);
错误:
error C2059: syntax error : ')'
如何禁用此功能"?
推荐答案
far
和near
是16位时代的内置编译器关键字.它们不再存在,也不再具有任何意义,但是出于向后兼容的原因,它们仍被定义为Windows标头中的宏.
far
and near
were built-in compiler keywords back in the 16-bit days. They no longer exist and they no longer have any meaning, but they're still defined as macros in the Windows headers for backwards compatibility reasons.
如果您不想要它们,只需取消定义它们(或不包括Windows标头)即可:
If you don't want them, just undefine them (or don't include the Windows headers):
#undef far
#undef near
这篇关于Visual Studio不允许我使用某些变量名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!