Page 1 of 1

Errors using fmt component

Posted: Mon Oct 16, 2023 2:20 am
by kabazorrou
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

Re: Errors using fmt component

Posted: Mon Oct 16, 2023 3:32 am
by ESP_Sprite
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.