|ARM Technical Support Knowledge Articles|
In ADS1.2 and RVCT 2.0 and later, the ARM libraries contain standard versions of the
printf family of functions, and also a more efficient variant of each which do not support all format specifiers, e.g.,
_scanf. The compiler generates calls to the more efficient variants where possible, e.g., where no floating point arguments are used.
In RVCT 2.1 and later, there are several variants of each function optimized for specific argument types, for example,
__0printf (RVCT 2.x/3.0),
__1printf (RVCT 3.1),
__2printf (RVCT 4.0),
_scanf_*. These more specific variants are smaller and faster than the general purpose versions. The ARM C compiler will generate calls to these functions instead of the standard function. For example, the RVCT 4.0 compiler will change the call to printf into a call to
__2printf but also emit references to symbols like
_printf_x depending on the format string/argument types. The linker takes these references into account and ensures that a specialised version that is smaller and faster is used. You could also see calls to variants of printf specific to a version of the ISO C standard, e.g.,
With RVCT 2.x you can disable the use of the variants if required (for example, if you are reimplementing
scanf) using the undocumented compiler switch
-Ono_fp_formats. When compiling with this option the compiler will only generate calls to the standard named function.
In RVCT 3.0 and later, you should use the documented option
--library_interface=aeabi_clib. This will also disable other optimizations for situations where you will be linking with a C library other than the RVCT library.
In ADS you should write a replacement function
_printf, e.g., which simply calls printf (likewise for
Article last edited on: 2009-06-26 17:21:29
Did you find this article helpful? Yes No
How can we improve this article?