14

I'm working with Arduino and Teensy boards from inside VS code. I can build and program everything fine, but the highlighting and code following functions built into VS Code don't work.

Previously, my custom headers weren't loading or highlighting, but this answer got that working for me. Now I have the right libraries on my include path (and I can click and follow them to the correct source) but some names still don't work:

enter image description here

enter image description here

My includePath appears to be configured correctly, as I mentioned I can follow the includes and it opens the correct sources:

"includePath": [
    "${workspaceFolder}/**",
    "C:/Program Files (x86)/Arduino/**",
    "C:/Program Files (x86)/Arduino/hardware/teensy/avr/cores/teensy/**",
    "C:/Program Files (x86)/Arduino/hardware/teensy/avr/libraries/ADC/**",
    "C:/Program Files (x86)/Arduino/hardware/arduino/avr/cores/arduino/**",
    "C:/Program Files (x86)/Arduino/hardware/arduino/avr/variants/standard/**",
    "C:/Program Files (x86)/Arduino/hardware/tools/avr/lib/gcc/avr/5.4.0/include/**"
]

I can confirm the header is on the includePath and has the names defined I'm looking for:

enter image description here

Somehow VS Code is still saying the identifier is undefined.

Any ideas?

Salvatore
  • 10,815
  • 4
  • 31
  • 69
  • 1
    You might want to have a look at VisualTeensy https://github.com/luni64/VisualTeensy/wiki/Quick-Start-Guide. It generates all required vsCode files for Teensy projects. Even if you don't want to use it, it has a life display of the generated files so you can easily experiment with Teensy settings and watch the effect on generated files. – luni64 May 07 '20 at 19:17
  • How are you adding IncludePaths for compilation/building? – Jonathan Aug 03 '23 at 01:24

1 Answers1

5

Just install the Arduino extension and run vscode command Arduino: initialize. You will need to select board and

File .vscode\c_cpp_properties.json and .vscode\arduino.json will automatically created.

CircleOnCircles
  • 3,646
  • 1
  • 25
  • 30
  • 6
    Doing this does not update the include path for the installed Arduino libraries. In my case I have a standalone portable installation and need to get the include path updated to include that location. – Ryan Higgins Aug 11 '22 at 22:27
  • @RyanHiggins This works with normal installation and arduino cli as well. – CircleOnCircles Aug 12 '22 at 09:19
  • This works! I'd add just one more thing, for newbies like me, you have to change the C/C++ Configuration from "Win32" to "Arduino" in the bottom right – Isaac Oct 16 '22 at 12:33
  • What if I want my own include path to my own libs? – Jonathan Jul 23 '23 at 06:38
  • My c_cpp_properties file wouldn't be updated by the extension until I deleted it and reran the initialize command. – E. Morell Aug 24 '23 at 09:44