*
*Home|Chinese|Japanese*About ARM|Forums|Events|News|Employment|Contact Us|Investors*
dotted rule
*ARM - the architecture for the digital worldARM - the architecture for the digital world
search
*
*
***
*MARKETS:PRODUCTS & SOLUTIONS:CONNECTED COMMUNITY:TECHNICAL SUPPORT:DOCUMENTATION*
*
technical support
*
*
****
*.Technical Support
*
*
*>>Home Page*
*
*.Obtaining Support*
*
*.FAQs*
*
**Development Tool FAQs*
**IP FAQs*
**Embedded Software FAQs*
**Artisan Physical IP FAQs (Login Required)*
*
*.Downloads*
*
*.Documentation*
*
*.Training*
*
*.Where To Buy*
*
*.Keil MCU Tools*
*
*.What's New*
*
*.ARM Newsgroups*
*
*.Active Assist On-site Services*
*
*
*
technical support FAQsask ARM*
*

Technical Support Search
*     (Advanced Search)
  FAQs   Documentation   Downloads   Forums

*

 
downarrowHow do the ARM Compilers handle printf, sprintf, fprintf and scanf?
Applies to: ARM Developer Suite (ADS), Compilers, Libraries, RealView Developer Kit (RVDK) for OKI , RealView Developer Kit (RVDK) for ST, RealView Developer Kit for XScale (RVXDK), RealView Developer Suite (RVDS) 2.0, RealView Developer Suite (RVDS) 2.1, RealView Developer Suite (RVDS) 2.2, RealView Development Suite (RVDS) 3.0, RealView Development Suite (RVDS) 3.1, RealView Development Suite (RVDS) 3.1 Professional

In ADS1.2 and RVCT 2.0 and later, the ARM libraries contain standard versions of the scanf and printf family of functions, and also a more efficient variant of each which do not support all format specifiers, e.g., _printf and _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, e.g. __0printf_fprintf_* and _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 expected function. For example, the compiler will change the call to printf into a call to __0printf but also emit references to symbols like _printf_str and _printf_int_dec 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 the ISO C standard, c90, e.g., __c89printf

With RVCT 2.x you can disable the use of the variants if required (for example, if you are reimplementing printf or 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 _scanf).






back to top

*
**
*4 dots*Other ARM Websites
*
shadow *LEGAL STATEMENTshadow