Errors using fmt component

kabazorrou
Posts: 2
Joined: Tue Oct 10, 2023 2:06 am

Errors using fmt component

Postby kabazorrou » Mon Oct 16, 2023 2:20 am

Hi everyone, I'v been trying to use a faster alternative to sprintf and came across the fmt library, which can be added as a component from here: https://components.espressif.com/compon ... ressif/fmt

I haven't been able to compile the code; I seem to be missing some libraries:
  1. In file included from /projects/analog_read/one_shot_ADC/main/one_shot_ADC.c:15:
  2. /projects/analog_read/one_shot_ADC/managed_components/espressif__fmt/fmt/include/fmt/format.h:36:10: fatal error: cmath: No such file or directory
  3.    36 | #include <cmath>             // std::signbit
  4.       |          ^~~~~~~
  5. compilation terminated.
  6. ninja: build stopped: subcommand failed.
Currently I'm using ESP-IDF v5.2-dev-823-g903af13e84-dirty

I don't know whether these libraries should be included in ESP-IDF or should come with my linux distribution.

Thanks

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: Errors using fmt component

Postby ESP_Sprite » Mon Oct 16, 2023 3:32 am

fmt is a c++ library. If you compile a file with a .c extension, esp-idf will use the C compiler to compile it, which doesn't understand c++. You can try to rename the file that uses fmt from bla.c to bla.cpp, but notice that there may be differences between C++ and C you can get caught in.

Who is online

Users browsing this forum: No registered users and 113 guests