MacOS:VSCode C/C++智能感知无法推断类型
MacOS Catalina 10.15.7,VSCode 1.64.2(通用):我的项目的智能感知没有出现任何问题,但由于某种原因它在某些情况下停止工作:
每当我将某些内容分配给“自动变量”时,例如: auto val = (float)foo;
我会收到智能感知错误: int val: 显式类型丢失 ('int'假定)C/C++(260)
。
类枚举无法正常识别,因此我无法使用 EnumClass::Enum
或获得任何与枚举相关的自动完成支持。
这些是最常出现的问题,但我想说智能感知通常无法正常工作。
我删除了与 VSCode 相关的所有内容(使用此:如何在 mac 上完全卸载 vscode< /a>)并仅启用 C/C++ 扩展重新安装,问题仍然存在。我有其他人在这个项目中使用相同的设置,但他们没有这个问题。我尝试了旧版本的扩展也没有成功。
有什么我可以尝试让它恢复工作的吗?
MacOS Catalina 10.15.7, VSCode 1.64.2 (Universal) :I had the intellisense working for my project without problems, but then for whatever reason it has stopped working in some cases:
whenever I assign something to an 'auto variable', for example: auto val = (float)foo;
I'd get intellisense error: int val: explicit type is missing ('int' assumed)C/C++(260)
.
Class enums are not recognised as they should, so I can't use EnumClass::Enum
or get any enum-related autocomplete support.
Those are the most reoccuring problems, but I'd say the intellisense generally doesn't work properly.
I removed everything related to VSCode (using this: How to completely uninstall vscode on mac) and reinstalled with just C/C++ extention enabled and the problem persists. I have other people using the same setup with this project and they don't have this problem. I tried older versions of the extention without success aswell.
Is there anything I could try to get it back to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题似乎是智能感知正在使用旧的 C++ 版本来确定语法。
解决此问题的方法是设置为一些较新的版本,例如 c++17
转到 VSCode 中的设置并搜索
Cpp Standard
,然后从下拉列表中选择c++17
或您使用的任何较新版本。如果您遵循 JSON 样式设置,则搜索以下
"C_Cpp.default.cppStandard": "c++17"
附上设置页面截图
The issue seems to be that intellisense is using older c++ version for determining the syntax.
The way to fix this is to set to some newer version like c++17
Go to settings in your VSCode and search for
Cpp Standard
and from the dropdown selectc++17
or any newer version that you use.In case you follow JSON style settings, then search for following
"C_Cpp.default.cppStandard": "c++17"
Attaching the screenshot of the settings page