是 Visual C++智能感知“更智能”比编译器

发布于 2024-12-02 10:06:11 字数 199 浏览 4 评论 0原文

我有以下场景。

我有一个基类,从中派生出一个类。一切看起来都很好,但是,每次我将鼠标光标悬停在基类的继承成员上时,智能感知都会显示它很好,EG BaseClass::SomeMember。但是,当我尝试编译时,编译器显示各种错误(它们与智能感知报告良好的变量和成员函数有关)。编译器说“它们不是有效的标识符”,它们不“属于全局名称空间”。有谁知道为什么会发生这种情况?

I have the following scenario.

I have a base class from which a class derives. Everything appears good however, every time I hover my mouse cursor over an inherited member of the base class, the intellisense shows it fine, EG BaseClass::SomeMember. However, when I try to compile, the compiler shows various errors(they are about the variables and member functions that the intellisense was reporting well). The compiler says 'they're not valid identifiers', that they don't 'belong to a global namespace'. Does anyone know why this is occurring?

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

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

发布评论

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

评论(3

南风几经秋 2024-12-09 10:06:11

如果这是 VC2010,那么是的,从某种意义上来说 Intellisense 更聪明。
他们转而使用 EDG 的编译器前端进行 IntelliSense,这是一种比 Microsoft 自己的编译器更严格、更符合标准的编译器。因此,在某些情况下,IntelliSense 和“真正的”编译器会不一致。

有时 IntelliSense 是错误的,因为它没有完整的图片(它在不同的上下文中运行,并且一次只处理一小部分代码),有时 Intellisense 是正确的,而编译器是错误的(就 C++ 标准而言)合规性),因为 EDG 的前端在这方面更好。

If this is VC2010, then yes, in a sense Intellisense is smarter.
They switched to using EDG's compiler frontend for IntelliSense, and that is a stricter, more standards-compliant compiler than Microsoft's own one. So there are cases where IntelliSense and the "real" compiler disagrees.

Sometimes IntelliSense is wrong because it doesn't have the complete picture (it runs in a different context, and processes only small snippets of the code at a time), and sometimes Intellisense is right and the compiler is wrong (in terms of C++ standard compliance), because EDG's frontend is just better in that respect.

疏忽 2024-12-09 10:06:11

不,智能感知绝对不是更聪明。你的代码被破坏了。针对代码的相关部分和您收到的错误消息提出一个单独的问题。

No, the intellisense is definitely not smarter. Your code is broken. Ask a separate question with the relevant parts of the code and the error messages you are getting.

故人的歌 2024-12-09 10:06:11

这取决于你对“聪明”的定义。智能感知不是一个成熟的编译器,但它内置了各种启发式方法,以帮助它处理无效代码。如果没有这些,那就完全没用了。

但这些启发式方法最终都只是猜测。有时它们会产生误导或错误。

It depends on your definition of "smarter". Intellisense is not a full-blown compiler, but it will have all sorts of heuristics built into it, to help it deal with invalid code. If it it didn't have these, then it would be completely useless.

But these heuristics are ultimately just guesses; sometimes they will be misleading or wrong.

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