The input/output library functions, such as the high-level
and the low-level
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
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
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.