Problem with include functional

If I put #include <ESP8266WebServer.h> in any file other than my main .ino file I get this error …

/root/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WebServer/src/ESP8266WebServer.h:27:22: fatal error: functional: No such file or directory
#include <functional>
compilation terminated.

Can someone explain this? I tried deleting ~/.platformio and .pioenvs.

My environment is …

platform = espressif8266
board = d1_mini
framework = arduino
build_flags = -Wl,-Tesp8266.flash.1m64.ld

Please provide a simple project to reproduce this issue.

I stripped it down to this and it still fails. First the .ino file

void setup() {}
void loop() {}

then the companiion C file

#include <ESP8266WebServer.h>

then the .ini file

platform = espressif8266
board = d1_mini
framework = arduino

There are no other files. I zipped up the project folder but I can apparently only upload image files here.

The pio installation was refreshed by deleting the ~/.platformio folder before this test.

Edit: The command I used to build in that folder was pio run.

I found my problem. The accompanying file was named web.c. Changing it to web.cpp fixed it. I am surprised because I have used C files in C++ projects for years. I thought it was the compiler that mattered not any file extension. I wonder how .ino files work.

Sorry for your trouble.

INO is ugly C++, where you have tried to use C++ in C file.