Referencing variables in other files VSCode

I’m using VSCode & PlatformIO. My arduino project is multiple .ino files. Autocomplete works just fine within a single file, but won’t pull in variables from other files in the same project. Is there an include I’m missing somewhere? I assumed it should work since they’re all in the same project.

In C/C++ you need to define your macros in each file you need to use them. The Arduino IDE does this for you.

So,

#define LED_BUILTIN 13

needs to be in each source file which references LED_BUILTIN. You can put this sort of thing in a separate header file and #include it as required.

Alternatively, you can add the following to platformio.ini:

build_flags=-DLED_BUILTIN 13

it will then be defined in every file that gets compiled.

If you have an actual variable in one source file:

const int ledPin = 13;

Then you need to add:

extern int ledPin;

to each and every source or header file which references it.

HTH

Cheers,
Norm.