IAR下printf格式化输出设置
试验环境LPLD固件库3.1
软件平台IAR 7.2
在格式化输出的过程中意外的发现一个奇怪的问题:
printf
函数在格式化输出的时候居然不支持%f %g的格式化形式,这是很奇怪的,因为同样的C语言,VC++里面是完全能够运行得到正确的结果的,在IAR下查看函数源文件发现是基于一个在common文件夹下的printf.c文件,源码中也没有看到对%f %g的支持,由此得出,这是一个阉割版的printf函数,系统调用的是这个函数所以,得出的结果与理想相差较大。
参考解决方案:
read.c修改后文件
/*******************
*
* Copyright 1998-2010 IAR Systems AB.
*
* This is a template implementation of the "__read" function used by
* the standard library. Replace it with a system-specific
* implementation.
*
* The "__read" function reads a number of bytes, at most "size" into
* the memory area pointed to by "buffer". It returns the number of
* bytes read, 0 at the end of the file, or _LLIO_ERROR if failure
* occurs.
*
* The template implementation below assumes that the application
* provides