Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESPHome Compile Error: "'optional' in namespace 'std' does not name a template type" #117

Closed
johndbritton opened this issue Oct 19, 2023 · 1 comment

Comments

@johndbritton
Copy link

I've been using this external component and everything has been working great up until I updated Home Assistant and ESPHome recently.

Since the update, compiling any ESPHome configurations that included this external component has failed with multiple errors like the following:

Compiling .pioenvs/studio-heat-pump/src/esphome/components/ota/ota_backend_arduino_esp32.cpp.o
In file included from src/esphome.h:24,
                 from src/esphome/components/mitsubishi_heatpump/espmhp.h:20,
                 from src/esphome/components/mitsubishi_heatpump/espmhp.cpp:21:
src/esphome/components/mitsubishi_heatpump/espmhp.h:163:14: error: 'optional' in namespace 'std' does not name a template type
         std::optional<std::chrono::duration<long long, std::ratio<60>>> remote_operating_timeout_;
              ^~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.h:163:9: note: 'std::optional' is only available from C++17 onwards
         std::optional<std::chrono::duration<long long, std::ratio<60>>> remote_operating_timeout_;
         ^~~

Followed by a bunch of error: '<VARIABLE>' was not declared in this scope messages.

I'm not exactly sure what change caused this, but I was able to resolve it by switching to C++17. In my ESPHome configuration I added the following:

esphome:
  platformio_options:
    build_unflags:
      - "-std=gnu++11"
    build_flags:
      - "-std=gnu++17"

This disables the std=gnu++11 flag and enables the std=gnu++17 flag in PlatformIO.

@johndbritton
Copy link
Author

Closing this as I've resolved my own problem, just posting here for folks who are searching for this answer.

@johndbritton johndbritton changed the title ESPHome Compile Error: "" ESPHome Compile Error: "'optional' in namespace 'std' does not name a template type" Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant