Snprintf not working float

I am programming in STM32F437. I am using SafeRTOS. The compiler is GCC.

In one task I am using snprintf()

to prepare a string with values.

The problem is it snprintf()

can't handle floating point numbers. It just ends the resulting line (s '\0'

) when it reaches a line %f

or %g

formatting line.

But, this is strange. snprintf()

in the task works without issue if I add a dummy call snprintf()

in main()

before starting RTOS.

Fake call:

char dummy[20];
snprintf(dummy, sizeof(dummy), "%g", 3.14159);

      

I found a similar solution here

But there is no answer as to why it works.

Any ideas what's going on?

+3


source to share


1 answer


The printf library does not include floating point support in some small implementations. Perhaps the dummy call somehow calls a more complete (and larger) library to be used?



0


source







All Articles