Standard printf/snprintf does not format floats

Hi, using a NUCLEO_L432KC with GCC. The standard printf or snprintf calls do not produce any floating point output.

If I switch the implementation to the minimal printf they do, however I need width padding. I don’t see any errors about exceeded flash size. What gives?

Hello Sid,

Printing floating point numbers is disabled in Mbed OS 6 by default. If you need width padding then try to build with the std library. Read here for more info.

Best regards, Zoltan

Yes, I’m aware. As I mentioned I’ve set:

"target.printf_lib": "std"

This does not provide me with a working floating point output. If I select the minimal printf but enable floating point output I do get the results I expect, but I am unable to do padding. I need padding.

The standard printf implementation is bugged. When enabled it will not do floating point output.

Never.
Are you using bare_metal? Then newlib-nano is used where floats are disabled by default.

Then what is the point of offering the minimal printf and the std printf? The lack of float, padding, etc, should be the domain of the minimal printf.

I’m not budging on this being a bug due to the subversion of expectations. If the standard printf is still going to be highly nonstandard then they should make that very obvious.

Until I can get confirmation this is intentional it seems the easiest path forward is reimplementing the padding.

The std setting is using the printf that is provided by the c-library, nothing Mbed specific. So with bare_ metal, additional compiler switches are needed for float support. With RTOS, the full newlib is used and printf works with all options.

I’m compiling with rtos.h included and using threads and intend to use the RTOS features. Do I need to do anything else to enable the full newlib?

no, with a mbed_app.json that Zoltan has shown in his link, it must work.