Loading...
 

System Workbench for STM32


Need Float output for printf

I have read that the floating point outputs for printf is turned off by default. How do I turn it on?

Hello,

I know that this thread is one year old, but to give an answer for other people that are looking for the answer, I will give it.

By default the float support is disabled. To enable it, add the linker flag: “-u _printf_float” in your project properties:
Properties -> C/C++ Build -> Settings -> MCU GCC Linker -> Miscellaneous -> Linker flags

Argentina

Hello, I’m asking you directly because you seem to know your way around OpenSTM32.

I’ve added the configuration that you posted, and it worked great, but compiling memory took up an extra 15kByte or so of memory just so the printf + float would work.

Do you know of any workaround that takes up less memory? Or I should write my own code to printf float numbers to save rom memory?

Regards,

Arielo


Very helpful @rreignier! I was fighting with printing floats for a while before I ran across this. Making my own “Printfloat” ended up being less accurate than enabling that flag. I included a screenshot to go along with your answer.

Thank you very much rreignier. Useful contribution!!! Thx

Hello!
There was the same need as in the topic starter. After installing this flag, the output stopped working at all. What is wrong?