Arduino extension for vscode - Syntax highlighting not working

Viewed 85

i am trying to use vscode and the arduino-cli. The extension is working correctly in veryfing and uploading the code to the board but it keeps highlighting arduino keywords (e.g.: digitalWrite) as errors, and as far as i can tell this should not happen. I am going to attach the arduino.json, c_cpp_properties.json files in because i read that the problem may lay here.

arduino.json:

{
    "sketch": "first.ino",
    "configuration": "cpu=atmega2560",
    "board": "arduino:avr:mega",
    "port": "COM5"
}

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\MinGW\\bin\\gcc.exe",
            "cStandard": "c89",
            "cppStandard": "c++98",
            "intelliSenseMode": "windows-gcc-x86"
        }
    ],
    "version": 4
}
1 Answers

Have you tried adding the paths of all libraries your Arduino IDE program comes with? Notice the line with the forcedInclude instruction that points to the path of the Arduino.h file.

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:/Program Files (x86)/Arduino/hardware/arduino/avr/cores/arduino",
                "C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/EEPROM/src",
                "C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/HID/src",
                "C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/SoftwareSerial/src",
                "C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/SPI/src",
                "C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/Wire/src"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",
                "ARDUINO_AVR_UNO",
                "ARDUINO_ARCH_AVR"
            ],
            "compilerPath": "C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-gcc.exe",
            "forcedInclude": [
                "C:/Program Files (x86)/Arduion/hardware/arduino/avr/cores/arduino/Arduino.h"
            ],
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}
Related