False intellisense errors in mbed project


What I’ve tried:

  • Rebuild IntelliSense index
  • Remove .vscode directory
  • Restart VS Code

I’m able to build the project but these errors are quite confusing.

Win 10 x64

[platformio]
packages_dir = C:\\Temp\\pio

[env:nrf52840_dk]
platform = nordicnrf52
framework = mbed
board = nrf52840_dk
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT
    -DMBED_TICKLESS

You should #include <EventQueue.h> and do a using events; after the mbed.h include. Also maybe try rebuilding the intellisense? Redirecting...

1 Like

i had that issue. Fixed it with #include “rtos.h”

You are right it fixed the problem, though it is even more confusing now. How it managed to compile the project without correct includes and usings?

I use Visual Studio for C# development and used to the fact that if something is highlighted with red it won’t compile until you fix it.

I tried to run a thermometer sample VS code shows a lot of errors, but it works.


As for me, it isn’t okay.

It’s likely it was only the IntelliSense error checker that wasn’t realising it should also look in that header file… if it compiles ok, but gets red underlines… it’s just IntelliSense not working properly… it happens sometimes, especially with more complex code… most times a rebuild of the intellisense cache livens it up, or sometimes extra includes are needed so it really does know where to find stuff.

I understand that this is only an IntelliSense problem, but as for me, it is a bug and probably it can be fixed.

For example, in the case of a thermometer project, everything works fine after adding

#define BLE_FEATURE_GATT_SERVER 1
#define BLE_ROLE_BROADCASTER 1

However, both these flags are already defined in “c:/UsersUserf/Documents/PlatformIO/Projects/nrf52840-bt-thermometer/.pio/build/nrf52840_dk/mbed_config.h”.

Just checked c_cpp_properties.json and it contains correct path (“c:/Users/User/Documents/PlatformIO/Projects/nrf52840-bt-thermometer/.pio/build/nrf52840_dk”). I have no idea no idea why it doesn’t work.

Ok, so that is probably either a Library Dependency Finder issue where it didn’t process the preprocessor macros (i.e. it needs lib_ldf_mode = chain+ or lib_ldf_mode = deep+ so it processes the defines properly or digs deeper into the include chain)… or because you haven’t compiled yet, so IntelliSense doesn’t know which defines will be active as they don’t technically exist, hence the errors will typically go away after a compile as those macros have appeared during a compile. I have a similar problem with code that has conditional includes triggered by defines, and it goes away after a compile.

In both cases, I tried:

  • Compile
  • Rebuild IntelliSense index
  • Remove .vscode directory
  • Restart VS Code

As for now, I decided to try Mbed Studio, at first glance it works better and faster.

1 Like