Why ESPHome might fail compiling a custom component with 'fatal error: string: No such file or directory'

I just spent several hours trying to figure out why ESPHome refused to compile a custom component I was working on. The error message I got was Compiling .pioenvs/datenzwerg-sleepy/src/esphome/components/sound_pressure/sound_pressure_sensor.c.o In file included from src/esphome/components/sound_pressure/sound_pressure_sensor.h:3, from src/esphome/components/sound_pressure/sound_pressure_sensor.c:1: src/esphome/core/component.h:3:10: fatal error: string: No such file or directory 3 | #include <string> | ^~~~~~~~ compilation terminated. Compiling .pioenvs/datenzwerg-sleepy/src/main.cpp.o *** [.pioenvs/datenzwerg-sleepy/src/esphome/components/sound_pressure/sound_pressure_sensor.c.o] Error 1 Other external and internal components compiled just fine, so that was quite a head scratcher, until I just finally noticed something in my source tree: my custom component’s source file had the file ending ....

July 14, 2023 · 1 min
Mastodon