Target dependencies on low-level functions in the C and C++ libraries
Higher-level C and C++ library input/output functions are built upon lower-level functions. If you define your own versions of the lower-level functions, you can use the library versions of the higher-level functions directly.
The following table shows the dependencies of the higher-level functions on lower-level functions.
fgetc()
uses __FILE
,
but fputc()
uses __FILE
and ferror()
.
Note
You must provide definitions of __stdin
and __stdout
if
you use any of their associated high-level functions. This applies
even if your re-implementations of other functions, such as fgetc()
and fputc()
,
do not reference any data stored in __stdin
and __stdout
.
Table key:
__FILE
, the file structure.__stdin
, the standard input object of type__FILE
.__stdout
, the standard output object of type__FILE
.fputc()
, outputs a character to a file.ferror()
, returns the error status accumulated during file I/O.fgetc()
, gets a character from a file.fgetwc()
fputwc()
__backspace()
, moves the file pointer to the previous character.__backspacewc()
.
Table 1-9 Input/output dependencies
High-level function | Low-level object | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |
fgets |
x | - | - | - | x | x | - | - | - | - |
fgetws |
x | - | - | - | - | - | x | - | - | - |
fprintf |
x | - | - | x | x | - | - | - | - | - |
fputs |
x | - | - | x | - | - | - | - | - | - |
fputws |
x | - | - | - | - | - | - | x | - | - |
fread |
x | - | - | - | - | x | - | - | - | - |
fscanf |
x | - | - | - | - | x | - | - | x | - |
fwprintf |
x | - | - | - | x | - | - | x | - | - |
fwrite |
x | - | - | x | - | - | - | - | - | - |
fwscanf |
x | - | - | - | - | - | x | - | - | x |
getchar |
x | x | - | - | - | x | - | - | - | - |
gets |
x | x | - | - | x | x | - | - | - | - |
getwchar |
x | x | - | - | - | - | x | - | - | - |
perror |
x | - | x | x | - | - | - | - | - | - |
printf |
x | - | x | x | x | - | - | - | - | - |
putchar |
x | - | x | x | - | - | - | - | - | - |
puts |
x | - | x | x | - | - | - | - | - | - |
putwchar |
x | - | x | - | - | - | - | x | - | - |
scanf |
x | x | - | - | - | x | - | - | x | - |
vfprintf |
x | - | - | x | x | - | - | - | - | - |
vfscanf |
x | - | - | - | - | x | - | - | x | - |
vfwprintf |
x | - | - | - | x | - | - | x | - | - |
vfwscanf |
x | - | - | - | - | - | x | - | - | x |
vprintf |
x | - | x | x | x | - | - | - | - | - |
vscanf |
x | x | - | - | - | x | - | - | x | - |
vwprintf |
x | - | x | - | x | - | - | x | - | - |
vwscanf |
x | x | - | - | - | - | x | - | - | x |
wprintf |
x | - | x | - | x | - | - | x | - | - |
wscanf |
x | x | - | - | - | - | x | - | - | x |
Note
If you choose to re-implement fgetc()
, fputc()
,
and __backspace()
, be aware that fopen()
and related
functions use the ARM layout for the __FILE
structure.
You might also have to re-implement fopen()
and
related functions if you define your own version of __FILE
.