hi I am using IAR c compiler, I am trying to print floating point value like
printf("version number: %f\n",1.4);
but I am always getting like below in console
version number:ERROR
help please thanks in advance kudi
hi I am using IAR c compiler, I am trying to print floating point value like
printf("version number: %f\n",1.4);
but I am always getting like below in console
version number:ERROR
help please thanks in advance kudi
The format string for the printf
function can specify floating point representations with a more explicit string:
printf("version number: %3.1f\n", 1.4);
I think this is the cause of the error message.
The '%3.1f' tells printf to use 3 characters, with one after the decimal place. The output should be
version number: 1.4
EDIT: Kudi, it seems the printf() function in the IAR compiler is quite different from the K&R printf() function.
This link is just one example which leads me to think that my copy of K&R is going to be no help at all. Sorry about that.
The error is probably due to your dlib configuration. Because of the focus on embedded targets with resource restrictions the behaviour/feature set of the iar c library (dlib) is configurable.
Look at Project/Options/General Options/Library Options.
From the docs:
*CHOOSING PRINTF FORMATTER The printf function uses a formatter called _Printf. The default version is quite large, and provides facilities not required in many embedded applications. To reduce the memory consumption, three smaller, alternative versions are also provided in the standard C/EC++ library.*
The #define _DLIB_PRINTF_SPECIFIER_FLOAT is available if printf knows floats.