Beheben: mbed printf() gibt literales %f aus in PlatformIO
English
Deutsch
Problem:
Sie verwenden Code wie
example.cpp
printf("%f\n", myFloat);in Ihrer mbed/PlatformIO-Anwendung, aber anstatt myFloat auszugeben, wird literales %f ausgegeben.
Lösung
mbed verwendet standardmäßig die minimal-printf-Bibliothek, die so konfiguriert ist, dass sie Platz auf dem Mikrocontroller spart. Daher ist die Float-Unterstützung (d.h. %f-Unterstützung) standardmäßig deaktiviert. Sie müssen sie aktivieren, indem Sie mbed_app.json im Stammverzeichnis des PlatformIO-Projekts mit "platform.minimal-printf-enable-floating-point": true hinzufügen:
mbed_app.json
{
"target_overrides": {
"*": {
"platform.minimal-printf-enable-floating-point": true
}
}
}Siehe die Seite Plattform-Konfigurationsoptionen für weitere Details und ähnliche Optionen.
Check out similar posts by category:
C/C++, Mbed, PlatformIO
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow