Intelli-sense - I may lack both, so I grovel. (offers no vars / arduino functions etc...)

Hello PlatformIO Community,

I am failing to get my Intellisense / PlatformOI installation to reliably offer standard Arduino functions, such as delay() or even my own variables (even vars/functions defined in the file I am currently editing).

It is also squiggly-lining ALL of my variables in my .h file saying redefinition of 'variable'

My success with intellisense is intermittent - works great one day, then the next day something in my world causes intellisense to offer almost no help (just a lot of things I do not recognize). I can not detect what I am doing wrong.

TRIED:
I inserted #include <Arduino.h> at the top of each of the five files in my project. I have tried packing #includes for all files into all files. Things improved when I deleted all includes in all files, except for my main .cpp, then went back to each file and added back in only includes required in that file - the squiggles disappeared and then intellisense began working wonderfully, but my .h redefinition problem persists. And if I fix all this today - I may unknowingly ruin it tomorrow.

Thanks,

Dan
San Jose

Environment:
I am using Win10, PlatformIO, and VSCode, Microsoft C++, (target device UNO). I made the switch from Arduino IDE two weeks ago. . My C++ coding skill level = “Stairway to Heaven” without the solo - not advanced, but no longer pitiful.

This is a common problem when people just declare their global variables in a .h file and include it from multiple .cpp files – you have to use a extern declaration (in header) and definition (in cpp file) pattern to do global variable sharing correctly. This has been discussed a lot of times in the forum already, see e.g.

If you still have problems, post the complete source code with error message.

Max - Thank you so much, those links nailed it - problem solved.

Dan
San Jose