PlatformIO VSCode Overwriting C/C++ Extension Compiler Path Causing Intellisense Issues

I’m having intellisense issues with a teensy 3.6 project in PlatformIO and I think the root of the issue is that the compiler path configured in C/C++ is invalid. My project compiles find and by running pio run -v I can see the compiler that platformio is using, however, when I try to fix the path in in C/C++ extension configuration it gets overwritten with intellisense rebuild. I know the overwrite is expected behavior, but how can I fix the compiler path that pio is configuring in the extension so I don’t have intellisense issues?

Please show those, it makes more sense to fix them for a regular PlatformIO project rather than hack around the compiler path to one that isn’t used during compilation.

@maxgerhardt I’m not trying to hack around the compiler path to one that isn’t used during compilation, I’m trying to fix the fact that the C/C++ Extension compiler path isn’t the one that’s used during compilation.

In main.cpp I have #include <i2c_t3.h> which is underlined red by intellisense giving the message “cannot open source file “i2c_t3.h” C/C++(1696)”. However, this isn’t an issue during build. So the Quick Fix options suggest modifying the include path which opens the C/C++ extension settings window where I noticed that the compiler path is set to

C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/gcc.exe.

When I run pio run -v I can see that platformio is using arm-none-eabi-g++ to build; I found the path of arm-none-eabi-g++ with where arm-none-eabi-g++ and that path is

C:\Program Files (x86)\GNU Tools Arm Embedded\9 2019-q4-major\bin\arm-none-eabi-g++.exe

Therefore, I’ve come to the conclusion that intellisense can’t find the teensy framework file i2c_t3.h because the c/c++ compiler setting is incorrect. Does that make sense?

Nope. PlatformIO is not using a globally installed arm-none-eabi-g++, it will use the compiler that the platform (teensy) / the project wants, downloaded from the PlatformIO trusted registry, into C:\Users\<user>\.platformio\packages\toolchain-gccarmnoneeabi\.

PlatformIO should not set this path in the .vscode/c_cpp_properties.json for a teensy project unless you have an environment with platform = native in the project and switched to that environment using the project environment switcher.

Can you please upload the project, or a minimal version thereof, that gives you these intellisense problems? Every environment that builds in PlatformIO and is the selected active environment should have working intellisense for every sourcefile used in the build for that environment.

@maxgerhardt I do have a native environment configured. That existed only to experiment with running native unit tests and in reality doesn’t really get used. I commented out the native environment section in the ini file and that fixed everything.

My environment was set to “Default” instead of env:teensy36. I’m guessing that’s either the first env in the ini or all envs in the ini. Either way, I’m just going to delete the native env and move on. Thanks for the quick responses!

Edit: If you think this is weird/undesired behavior, I can still create a sample project for you and upload to github.