Tailoring input/output functions in the C and C++ libraries
The input/output library functions, such as the high-level fscanf() and fprintf(),
and the low-level fputc() and ferror(),
and the C++ object std::cout, are not target-dependent. However,
the high-level library functions perform input/output by calling
the low-level ones, which themselves call the system I/O functions,
which are target-dependent. To retarget input/output, you can either
avoid the high-level library functions, or redefine the lower-level functions,
either the low-level library functions or, below them, the system
I/O functions, and then use them through the high-level library
functions.
Whether redefining the low-level library functions or redefining
the system I/O functions is a better solution depends on your use.
For example, UARTs write a single character at a time and the default fputc() uses
buffering, so redefining this function without a buffer might suit
a UART. However, where buffer operations are possible, redefining
the system I/O functions would probably be more appropriate.
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.