VS Code shows spurious compile error

I’ve just started with Platform IO in Visual Studio Code, using the mbed framework and a STM32F103C board, and I’ve successfully compiled and uploaded a blink app via a ST-LINK clone. However, Visual Studio Code shows a compile error:

'mbed.h' file not found (1, 10)

Even though the app works, it’s quite distracting to have this spurious error highlighted in the Problems view and as red squiggly lines in the code. So what could be wrong with my installation?

The error occurs with every include file from the platformio directory, not just mbed.h.

mbed.h exists in /Users/abc/.platformio/packages/framework-mbed and the directory is the first entry in the includePath section of c_cpp_properties.json. Strangely enough, IntelliSense even propose mbed.h if I type #include "mb.

I probably need to mention that I’m using macOS High Sierra, the latest Visual Studio Code (1.27.2), PlatformIO 3.6.1a4. And I have used Visual Studio Code before for other, non-PlatformIO C/C++ projects.

The app code is as simple as it gets:


#include "mbed.h"
DigitalOut myled(PB_12);
int main() 
        myled = 1;
        myled = 0;


platform = ststm32
board = bluepill_f103c8
framework = mbed
upload_protocol = stlink

Huh? You’ve successfully compiled and uploaded the code wihth Visual Studio Code but Visual Studio Code shows a compile error?

Yes. I guess it’s part of IntelliSense. The red squiggly lines appear while typing and before saving the file.

The problem has been solved. I’ve disabled several VS Code extension that I had used for other projects. Now the spurious errors are gone. I assume one of the extension has also compiled the code in the background but was unaware of all the include paths.