为什么Arduino Intellisense无法在VSCode中工作?

时间:2018-07-31 13:43:45

标签: arduino visual-studio-code

我在VSCode中安装了Arduino扩展Arduino extension,该扩展本来应该包含intellisense,但似乎没有用。这是我的c_cpp_properties.json:

c_cpp_properties.json

这是一个智能感知无法正常工作的示例:

intellisense not working

如您所见,智能感知应该能够预测关键字Serial,但不能。

我安装了命令行工具。我应该在“ includePath”属性中添加缺少的目录吗?

2 个答案:

答案 0 :(得分:1)

将缺少的行添加到c_cpp_properties.json中(并将某些文件名更改为与Mac等效的文件名) 尤其是使用"defines": [ "USBCON" ]使Serial类可以与智能感知一起使用

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "<arduino ide installation folder>\\tools\\**",
                "<arduino ide installation folder>\\hardware\\arduino\\avr\\**",
                "<arduino ide installation folder>\\hardware\\tools\\**",
                "<arduino ide installation folder>\\hardware\\arduino\\avr\\cores\\arduino"
            ],
            "forcedInclude": [
                "<arduino ide installation folder>\\hardware\\arduino\\avr\\cores\\arduino\\Arduino.h"
            ],
            "intelliSenseMode": "msvc-x64",
            "compilerPath": "<arduino ide installation folder>\\hardware\\tools\\avr\\bin\\avr-gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "defines": [
                "USBCON"
            ]
        }
    ],
    "version": 4
}

答案 1 :(得分:0)

尝试将此路径添加到“浏览”中,如“ includePath”中一样

   "browse": {
      "limitSymbolsToIncludedHeaders": false,
      "path": [
        "arduino_install_dir/hardware/tools/avr/avr/include",
        "${workspaceRoot}"
      ]
    },