【问题标题】:Trouble getting suggestions in vs code在 vs 代码中获取建议时遇到问题
【发布时间】:2021-08-26 11:58:07
【问题描述】:

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

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

【问题讨论】:

  • 我猜。 Intellisense 经常根据文件名的扩展名确定提供什么。因此,也许可以使用例如 .cpp 扩展名保存文件,然后查看 VS 是否为您提供了更好的建议。

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


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    我可以看到文件名为 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

    【讨论】:

    • 当你创建一个新文件时,它会让你“选择一种语言”——但它不会打开智能感知。这就是混乱的来源。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-16
    • 2021-12-30
    • 1970-01-01
    • 2018-10-26
    • 1970-01-01
    • 2021-05-03
    相关资源
    最近更新 更多