std::FILE(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

std::FILE(3)

okay so this is std::FILE(3), straight out of the C++ Standard Libary β€” yes bestie, that spelling is in the header, and honestly? iconic. It’s the C++ standard library page for the C stream type, and we’re gonna get into it. 🫢

🌸 NAME 🌸

std::FILE - std::FILE

That’s the name, no notes. It’s literally the type that represents a C stream in C++ land. πŸ’…

✨ Synopsis ✨

Defined in header <cstdio>, and the typedef is exactly this:

typedef /* unspecified */ FILE;

Each std::FILE object denotes a C stream. 🫢

πŸ’€ technical caveat, bestie: the C standard (referenced by the C++ standard) does not specify whether std::FILE is a complete object type. While it may be possible to copy a valid std::FILE, using a pointer to such a copy as an argument for an I/O function invokes unspecified behavior. In other words, std::FILE may be semantically non-copyable.

I/O streams can be used for both unformatted and formatted input and output. Furthermore, the functions that handle input and output can also be locale-sensitive, such that wide/multibyte conversions are performed as necessary. 🌈

🧠 Notes 🧠

POSIX explicitly requires that the LC_CTYPE facet of the currently installed C locale be stored within the FILE object the moment the stream’s orientation becomes wide; POSIX requires that this LC_CTYPE facet be used for all future I/O on this stream until the orientation is changed, regardless of any subsequent call to std::setlocale. πŸŽ€

It is intended that each line of text be composed of data that are essentially human-readable. POSIX implementations do not distinguish between text and binary streams (there is no special mapping for '\n' or any other characters). ✨

πŸ‘€ See also πŸ‘€

here’s the squad:

  • basic_streambuf abstracts a raw device (class template)
  • basic_filebuf implements raw file device (class template)
  • stdin expression of type FILE* associated with the input stream
  • stdout expression of type FILE* associated with the output stream
  • stderr expression of type FILE* associated with the error output stream (macro constant)
  • C documentation for FILE

that’s the whole vibe πŸ’– β€” source/version is http://cppreference.com, date 2024.06.10, and yes she ate. πŸ«ΆπŸ‘‘

πŸ“¦ where this page comes from