Standard I/O Packages (GNAT Reference Manual)

### 12.1 Standard I/O Packages ¶

The Standard I/O packages described in Annex A for

- Ada.Text_IO
- Ada.Text_IO.Complex_IO
- Ada.Text_IO.Text_Streams
- Ada.Wide_Text_IO
- Ada.Wide_Text_IO.Complex_IO
- Ada.Wide_Text_IO.Text_Streams
- Ada.Wide_Wide_Text_IO
- Ada.Wide_Wide_Text_IO.Complex_IO
- Ada.Wide_Wide_Text_IO.Text_Streams
- Ada.Stream_IO
- Ada.Sequential_IO
- Ada.Direct_IO

are implemented using the C library streams facility; where

- All files are opened using `fopen`.
- All input/output operations use `fread`/`fwrite`.

There is no internal buffering of any kind at the Ada library level. The only buffering is that provided at the system level in the implementation of the library routines that support streams. This facilitates shared use of these streams by mixed language programs. Note though that system level buffering is explicitly enabled at elaboration of the standard I/O packages and that can have an impact on mixed language programs, in particular those using I/O before calling the Ada elaboration routine (e.g., adainit). It is recommended to call the Ada elaboration routine before performing any I/O or when impractical, flush the common I/O streams and in particular Standard_Output before elaborating the Ada code.