Hey,
i started today using VS Code for programming Arduino sketches. I opened a sketch that I programmed with the Arduino IDE. After opening the file i selected my board and the arduino.json + c_cpp_properties.json files were created in the .vscode folder.
With the help of the "Show Fixes" dropdown menu I added the following to my c_cpp_properties.json file:

I still have 2 warnings:
#include errors detected. Please update your includePath. IntelliSense features for this translation unit (D:\My\Path\to\the\script\myscript.ino) will be provided by the Tag Parser.
cannot open source file "avr32/io.h" (dependency of "SPI.h")
When I peek the definition it clearly shows that its not defined.

However when I open the script with the Arduino IDE
Why is that?
Hope you can help me.
Cheers
I think you need to add some defines to the configuration. Here is what I use for the MKRWAN1300:
"defines": [
"ARDUINO=100",
"ARDUINO_ARCH_SAMD",
"ARDUINO_SAMD_MKRWAN1300",
"__SAMD21G18A__",
"BOARD_ID_arduino_mkrwan1300",
"_VARIANT_ARDUINO_MKRWAN1300_"
],
Since you are using AVR, your defines will be different but conceptually, you need to add them the have the conditional defines work.
Also, there is a file "includes.cache" in the build directory ... look inside that file and make sure all the includes listed in there are in your configuration.
I don't know why but i deleted the .vscode folder and started the setup process again.
I now have a settings.json file with the parameter"C_Cpp.intelliSenseEngine": "Tag Parser".
It seems the intellisense works now. Maybe its because of that but i don't know that.
Nevertheless I will add defines for my board if i can figure out what to type in there :).
Where did you get your define values from?
I am also getting this error using an Arduino/Genuino Uno board on Windows 10.
cannot open source file "avr32/io.h" (dependency of "SPI.h")
This is my c_cpp_properties.json file:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"C:\\\\Program Files (x86)\\\\Arduino\\\\hardware\\\\arduino\\\\avr\\\\**",
"C:\\\\Program Files (x86)\\\\Arduino\\\\hardware\\\\tools\\\\**",
"C:\\\\Program Files (x86)\\\\Arduino\\\\tools\\\\**",
"C:\\\\Program Files (x86)\\\\Arduino\\\\libraries\\\\**",
],
"forcedInclude": [
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Arduino.h"
],
"intelliSenseMode": "msvc-x64",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.20.27508/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"defines": [
"USBCON"
]
}
],
"version": 4
}
@ueberBrot Apologies, I missed your post back in October. Did you figure this one out?
A good place to look is in the compiler and linker configurations. Recently I found that the platform.txt and boards.txt files have relevant configurations in them and I think if you pick the defines from these they are the only ones you need. You can also dig through the header files to figure out which ones you require. This is what I originally did but it is a more tedious process.
Regarding the Tag Parser ... this is a sub optimal solution. You really are not getting the benefit of IntelliSense when you are using the Tag Parser. The difference is huge.
@sslupsky thank you for your replay. I never figured it out and I stopped looking for it.
Regarding the Tag Parser ... this is a sub optimal solution. You really are not getting the benefit of IntelliSense when you are using the Tag Parser. The difference is huge.
Yeah exactly. Working with it I had many problems during the build process and that's why I switched back to the Arduino IDE.
Later I found an alternative with PlatformIO and I'm happy with it so far.
FYI, I know this issue is closed by I was able to get around this issue in my case by doing the following two things:
Add a direct path to the SPI library to the "includes" array, as follows:
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/SPI/src"
Modify the following two variables:
"compilerPath": "C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-gcc.exe",
"intelliSenseMode": "gcc-x86",
Number 2 is needed as without it the SPI.h library has tons of IDE issues per MSVC. By doing this my project builds correctly and has no more squiggly lines issues.
I believe this is a problem due to the C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/SPI/keywords.txt file
I'm not sure if this is for everyone, but line 2 of my file is # Syntax Coloring Map SPI, when I think it should be # Syntax Coloring Map for SPI.
All other libraries in the C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/ directory have line 2 of their keywords.txt at # Syntax Coloring Map for {library name} and the recursive imports from higher directories does work for these
I posted this issue on the arduino github repo
I believe this is a problem due to the C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/SPI/keywords.txt file
I'm not sure if this is for everyone, but line 2 of my file is # Syntax Coloring Map SPI, when I think it should be # Syntax Coloring Map for SPI.
That's only a comment. It is indeed a typo, and I am not opposed to it being corrected (though I'm not in a position to merge PRs in the Arduino boards platform repositories), but a typo in a comment should never have any functional effect. If for some reason this project is parsing the comments in keywords.txt files (which I very much doubt), then that should be considered a faulty approach. There is no specification for any format for these comments. The library author is free to add anything they like in comments in these files, or no comments at all if they prefer.
This problem still persists. Clean install of arduino and vscode extensions. First try with SPI library and got the exact same error that avr32/io.h can't be found. Why is this issue closed though?
Having this problem too. Although Arduino IDE is compiling and VSCode also. All the dependency stuff is like Chinese to me! The dependency will probably be solved via another path. Which one????? stays a mystery.
Most helpful comment
FYI, I know this issue is closed by I was able to get around this issue in my case by doing the following two things:
Add a direct path to the SPI library to the "includes" array, as follows:
"C:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/SPI/src"
Modify the following two variables:
"compilerPath": "C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-gcc.exe",
"intelliSenseMode": "gcc-x86",
Number 2 is needed as without it the SPI.h library has tons of IDE issues per MSVC. By doing this my project builds correctly and has no more squiggly lines issues.