1.12 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. These low-level functions call system I/O functions that are target-dependent.

To retarget input/output, you can:
  • Avoid the high-level library functions.
  • Redefine the low-level library functions.
  • Redefine the system I/O 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.
Related concepts
1.14 The C library printf family of functions
1.15 The C library scanf family of functions
1.16 Redefining low-level library functions to enable direct use of high-level library functions in the C library
1.17 The C library functions fread(), fgets() and gets()
1.18 Re-implementing __backspace() in the C library
1.19 Re-implementing __backspacewc() in the C library
1.20 Redefining target-dependent system I/O functions in the C library
Related reference
1.13 Target dependencies on low-level functions in the C and C++ libraries
1.6.6 Direct semihosting C library function dependencies
1.6.7 Indirect semihosting C library function dependencies
1.7.1 Building an application without the C library
4.38 _sys_close()
4.39 _sys_command_string()
4.40 _sys_ensure()
4.42 _sys_flen()
4.43 _sys_istty()
4.44 _sys_open()
4.45 _sys_read()
4.46 _sys_seek()
4.47 _sys_tmpnam()
4.48 _sys_write()
4.8 _fisatty()
Non-ConfidentialPDF file icon PDF versionARM DUI0378G
Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights reserved.