Visual Studio doesn't allow me to use certain variable names

不打扰是莪最后的温柔 提交于 2019-11-28 07:49:15

问题


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:

error C2059: syntax error : ')'

How can I disable this "feature"?


回答1:


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.

If you don't want them, just undefine them (or don't include the Windows headers):

#undef far
#undef near


来源:https://stackoverflow.com/questions/8948493/visual-studio-doesnt-allow-me-to-use-certain-variable-names

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!