3 ms·
> But what use case do you have for printf that can't be implemented with println!/format! and friends? I'm guessing they mean that the format! machinery is ra
by masklinn 6y ago
> But what use case do you have for printf that can't be implemented with println!/format! and friends?
I'm guessing they mean that the format! machinery is rather complex and brings in a lot of code. That it's also somewhat slow is a recurring concern .
Have none of the embedded folks created a specialised version of format! which is not generic, and basically only supports the types and styles which c's printf supports?
edit: there's ufmt though it seems somewhat inactive and I've no idea how good it is: https://github.com/japaric/ufmt https://github.com/japaric/ufmt
> Optimized for binary size and speed (rather than for compilation time)
> No dynamic dispatch in generated code
- rcxdude 6y agoThere's defmt which I think i think is even better (it implements basically the same thing as I have used in a commercial C++ embedded project for a few years, and was sorely missing any open source equivilent when I was first trying to implement it). formatting strings on an embedded device is pointless and wasteful. Heck, formatting log lines before they are displayed to the user is actively harmful to interpreting them! Defmt basically gives embedded projects structured logging and a substantial bandwidth, cpu, and space overhead gain. https://ferrous-systems.com/blog/defmt/ https://ferrous-systems.com/blog/defmt/
- masklinn 6y agodefmt looks cool for logging but I'd think there are cases where you want to format strings somehow in order to present them to the user e.g. audio track information or whatnot.