PlatformIO Community

Identifier "boolean" is undefined


Getting lot of “identifier “XXX” is undefined” messages in “Problems” panel (highlighted as an error in editor too)

Just simple project imported from Arduino into VS Code (with IO installed, of course).
What can be reason and how to fix this?


boolean is a type defined within the first few lines of Arduino.h as

typedef bool boolean;

Where bool is a primitive C++ type. If your IDE can’t resolve that type (highlight the type, right click, “Go To Definition (F12)”), make sure you have #include <Arduino.h> as the first line of your file. You might need to re-build your project index (by executing the build target PLATFORMIO_REBUILD_PROJECT_INDEX) or rebuild your IDE’s C/C++ index by closing and re-opening the project. If none of that works you need us to show the code in which the Intellisense fails to resolve that type.


Solved. Thanks.
Maybe add this by default when import Arduino project? Or, at least, make some notice about this when import?
Because none of Arduino samples contain explicit “#include <Arduino.h>”…