What kind of issue is this?
Configuration
Operating system: KDE Neon 5.27
PlatformIO Version: 6.1.7
Description of problem
ClangD includes either system header files or doesn't see them at all.
If you include Arduino.h you'll get this error if you don't have gcc-multilib installed on your system:
clang: 'bits/libc-header-start.h' file not found [pp_file_not_found].
If you do have gcc-multilib on your system then you'll get this error instead:
clang: In included file: 'avr/pgmspace.h' file not found [pp_file_not_found].
When looking into the Arduino.h file I can see that eg. the bits/libc-header-start.h is from the system header files instead of the Arduino ones:
Image

Steps to Reproduce
pio project init --board uno
touch src/main.cpp
- Open
main.cpp
- Add
#include <Arduino.h> and see the error
pio run -t compiledb
- If present from the start create some header file in the
include directory and do the same as in main.cpp
Expected Results
ClangD correctly solving header paths so the code completion works
If problems with PlatformIO Build System:
The content of platformio.ini:
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:uno]
platform = atmelavr
board = uno
framework = arduino
Source file to reproduce issue:
Additional info
While writing this issue I figured out that it works as expected if you first run pio project init --board uno && pio run -t compiledb and then create the main.cpp file with #include <Arduino.h>. If you do it the other way around or you run pio run -t compiledb after creating the main.cpp file you'll get these errors.
What kind of issue is this?
Configuration
Operating system: KDE Neon 5.27
PlatformIO Version: 6.1.7
Description of problem
ClangD includes either system header files or doesn't see them at all.
If you include
Arduino.hyou'll get this error if you don't havegcc-multilibinstalled on your system:clang: 'bits/libc-header-start.h' file not found [pp_file_not_found].If you do have
gcc-multilibon your system then you'll get this error instead:clang: In included file: 'avr/pgmspace.h' file not found [pp_file_not_found].When looking into the
Arduino.hfile I can see that eg. thebits/libc-header-start.his from the system header files instead of the Arduino ones:Image
Steps to Reproduce
pio project init --board unotouch src/main.cppmain.cpp#include <Arduino.h>and see the errorpio run -t compiledbincludedirectory and do the same as inmain.cppExpected Results
ClangD correctly solving header paths so the code completion works
If problems with PlatformIO Build System:
The content of
platformio.ini:Source file to reproduce issue:
Additional info
While writing this issue I figured out that it works as expected if you first run
pio project init --board uno && pio run -t compiledband then create themain.cppfile with#include <Arduino.h>. If you do it the other way around or you runpio run -t compiledbafter creating themain.cppfile you'll get these errors.