无法在 vs 代码中获取建议

时间:2021-06-09 13:10:00

标签: c++ visual-studio-code intellisense

我正在学习 C++ 代码并使用 vs 代码作为 IDE。一切顺利,但现在我在编写代码时没有得到建议。我正在使用 Intellisense 的 C/C++ 扩展。我尝试重新安装它,重置其设置,但没有任何效果。请帮忙。

This is the only suggestion it shows when I type #include.

2 个答案:

答案 0 :(得分:0)

您需要保存(cmd+s / ctrl+s)文件才能让智能感知工作。

答案 1 :(得分:0)

我可以看到文件名是 Untitled-1。 Intellisense 将无法工作,因为您需要通知 VS Code 它是一个 C/C++ 文件。

您应该创建一个新文件并使用 .c 或 .cpp 扩展名保存它。

如果您想为 QT5 或 OpenCV 等外部库添加自动完成功能,您需要按照 this link 配置智能感知。将外部库的包含路径添加到 c_cpp_properties.json 中的 includePath。

示例 -

    "includePath": [
          "${myDefaultIncludePath}", // Adds intellisense for the files from current workspace folder. 
          "path/to/include/folder"
     ]

Reference for c_cpp_properties.json

相关问题