PlatformIO stm32: Intellisense for google mock is broken


I have a project with a STM32 which I am coding in VS code platform IO.

My problem, is that intellisense for google mock simply can not work when the native test project is unable to build (because the “main” project relies on stm32 hal libraries). See below image for the error.

For clarity, pio test works fine:

Uploaded small project which shows the problem here:
basprins/platformiogmockintellisense (

Anybody can confirm that this is a bug (and hopefully it will be solved), or that there is a way to get around this with a workaround?

PS: I understand that I can’t build my native environment, since it will compile all c/c++ files which includes stm32 hal libraries. That’s fine. The pio test commands builds only my test runners / test files and will only include my “none hal dependent” classes. But if platformio intellisense would be able to resolve the googlemock headers (they can, using pio test, after all) it would make a huge difference !

Works for me.

Just make sure you use the project environment switcher to select the native environment of your project. If in doubt, do a IntelliSense rebuild with Ctrl+Shift+P → Rebuild IntelliSense.

1 Like

OMG… The hours spend on this, and then hearing how dead simple the fix is; it hurts deep inside.

Thx a million for the lesson though! One I’ll never forget