Can someone elaborate? I always treated FILE as opaque, but never imagined people could poke into it?
by abnercoimbre 10 minutes ago
The standard doesn't specify any serviceable parts, and I don't think there are any internals of the struct defined on Linux, at least not for musl libc. However, on OpenBSD, it did seem to have some user-visible bits:
https://github.com/openbsd/src/commit/b7f6c2eb760a2da367dd51...
If you expose it, someone will probably sooner or later use it, but probably not in any sane / portable code. by recipe19 2 minutes ago
People use reflection for monkey patching and complain when using compiled languages less supportive of such approaches.
So it wouldn't surprise me, that a few folks would do some tricks with FILE internals. by pjmlp 2 minutes ago
However, who should really rely on internals of FILE? Isn't this a bad practice?
by p0w3n3d 9 minutes ago
In general, it is a bad practice. However, it can be useful for some low-level libraries. For example, https://github.com/fmtlib/fmt provides a type-safe replacement for `printf` that can write directly to the FILE buffer providing comparable or better performance to native stdio.
by vitaut 4 minutes ago