Add sources' and headers' directories for VS Code IntelliSense

IDE: VSCode + PlatfotmIO + ESP32 IDF

Hi,
I hope you can help me.
Initially, I desired to post this in VS Code support, but I’ve found PlatformIO community more appropriate cause an issue is related more with Platformio than VS Code.

I want VS Code’s IntelliSense to make GoTo Declaration\Definition in all IDF SDK directories. But not all directories is used in project, so IntelliSense doesn’t go there.
VS Code Community recommends to add needed paths to c_cpp_properties.json of the project.
But in c_cpp_properties.json there’s a notation:

“!!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE Redirecting...

Yes, I’ve tried append needed path/* there, but c_cpp_properties.json is rewritable after reopen of VS Code, and after project rebuilding.
I think advices to use build_flags in platformio.ini is acceptable only for headers nor source files.
So How could I add src pathes for IntelliSense using PlatformIO in VS Code?
Thanx in advance, guys.

Yes, please use Redirecting...

I’ve tried.
I’ve appended platformio.ini with paths to tasks.c:

[env:specific_inclibs]
build_flags =
-I/home/USER/.platformio/packages/framework-espidf/components/freertos
-L/home/USER/.platformio/packages/framework-espidf/components/freertos

I have in application’s main.c:

vTaskDelay(1000 / portTICK_RATE_MS);

Ctrl+Clicking on it I’ve gotoed to declaration in
/home/USER/.platformio/packages/framework-espidf/components/freertos/include/freertos/task.h:

void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;

Ctrl+Clicking on it here to get a definition in tasks.c nothing happens.

It doesn’t help. It seems IntelliSense doesn’t care these compiler options.

  1. What flag exactly should I use for source directory in this case?
  2. How should I care about sources in many directories in SDK?

Could you try to delete .vscode folder from a project and restart VSCode?

Hello, I’m having exactly the same issue, but with ST HAL libs instead of FreeRTOS.

The program compiles, builds, flashes, debugs, etc. correctly.

The only problem is, intellisense doesn’t recognise where the header files are located, since c_cpp_properties does NOT include the path to the HAL (inside .platformio/packages…etc.). I’ve tried compiler flags (-I, -L and more) to no avail. Is there any way to force an extra path into c_cpp_properties from platformio.ini?

And yes, tried reloading intellisense, reopening vsc, deleting .vscode… I have seen more open threads with this same issue, so any luck someone looks into it?

Thanks for the project you’ve created BTW. Just started testing and it’s amazing!

If it compiles, the header files should be found by PlatformIO which means they should be transferred into the c_cpp_properties.json automatically. Can you post the exact project you’re having problems with?

It’s the unit tests example project ( Unit Testing with PlatformIO: Part 2. Running tests on an embedded target | PlatformIO Labs (piolabs.com)).

TL;DR you can check the platform.io and c_cpp_properties pics.

If I manually add the path to c_cpp_properties, it does work. Then again, it just gets rebuild by platformio every time, so that’s not a viable solution. What I’m looking for is a way to include said path in the c_cpp_properties by using platformIO config.



Jomarra96/NucleoF401RE_UnitTest_CICD (github.com)

If you need any more info, please let me know, and thanks again for your help!

Well the project has two environments, have you made sure to project environment selector to select env:nucleo_f401re?

That was precisely the issue, thanks!