Basis ist die avr-libstdcpp auf github.
Dazu sind einige Anpassungen nötig, die in einer Datei platform.local.txt stehen.
Pfad: ...\arduino-1.8.19\portable\packages\arduino\hardware\avr\1.8.6\
Anpassungen für die IDE 2.x
C:\Users\xyz\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\
In den Pfaden eine Datei namens platform.local.txt erstellen und folgenden Inhalt einfügen.
Den Pfad zu eurem Ablageort der Toolchain und avrLibStdCpp (-isystem) natürlich anpassen. ;-)
compiler.path=C:\avrToolchain\avr-gcc-14.2.0_mingw32_binutils2.43_avrLibc2.2.1/bin/
#compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++17 -fno-exceptions -fpermissive -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -fwrapv
#compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++20 -fno-exceptions -fpermissive -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -Wno-volatile -Wl,-u,vfprintf -lprintf_flt -lm
#compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++20 -fno-exceptions -fpermissive -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -Wno-volatile
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++23 -fno-exceptions -fpermissive -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -Wno-volatile -isystem "C:\avrToolchain\avrLibStdCpp\include"
#compiler.cpp.extra_flags=-fno-sized-deallocation -Wall -Wextra -Werror
compiler.cpp.extra_flags=-fno-sized-deallocation -Wall -Wextra
#compiler.cpp.extra_flags=-fno-sized-deallocation -Wall
Das wars. :-)
Ein erster Test Sketch.
#include <Streaming.h>
#include <cmath>
void setup()
{
Serial.begin(9600);
Serial.println(square(25));
Serial.println(square(25.0d));
Serial.println(squaref(25.0));
Serial.println(sqrtf(250));
Serial.println(sqrt(250));
Serial.println(ceil(4711.42));
Serial.println(floor(4711.42));
Serial.println(ldexp(3.0,2));
Serial.println(sin(0.5));
Serial.println(signbit(0.5));
Serial.println(signbit(-0.5));
double f = 123.45;
double f3;
double f2 = modf(f, &f3);
Serial << "modf(" << f << ") = " << f3 << " + " << f2 << endl;
f2 = std::exp2(5);
Serial << "exp2(5) (2^n) = " << f2 << endl;
Serial << "round(5.4) " << round(5.4) << " lround(5.4) " << lround(5.4) << endl;
Serial << "round(5.49) " << round(5.49) << " lround(5.49) " << lround(5.49) << endl;
Serial << "round(5.5) " << round(5.5) << " lround(5.5) " << lround(5.5) << endl;
Serial << "round(5.6) " << round(5.6) << " lround(5.6) " << lround(5.6) << endl;
}
void loop()
{ }