Visual Studio 不允许我使用某些变量名称

发布于 2024-12-28 09:56:46 字数 244 浏览 2 评论 0原文

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

z = 1.0/(far - near);

错误:

error C2059: syntax error : ')'

如何禁用此“功能”?

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"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

jJeQQOZ5 2025-01-04 09:56:46

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

如果您不需要它们,只需取消定义它们(或不包含 Windows 标头):

#undef far
#undef near

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文