An opaque type hides its representation or purpose from the code that manipulates it. Programs use the type through functional interfaces rather than inspecting its internals. section 8.3.1
Writing to a stream without inspecting it
The C library exposes FILE* for streams. Code can pass a stream to fputc or fputs and test whether the pointer is null, but it need not know what FILE contains. Reimplementing puts with fputs(stdout) followed by fputc('\n', stdout) demonstrates the intended boundary: use operations, not representation. section 8.3.1
TAKEAWAY
- Specify opaque types through functional interfaces. section 8.3.1
- Do not rely on implementation details, including historical interface quirks. section 8.3.1
- Treat pointers as opaque early, while postponing their memory-related purpose. section 6.0
- Use thrd_t to identify threads through thrd_create and thrd_join without exposing its representation. section 18.0
int fputc(int c, FILE* stream);
int fputs(char const s[static 1], FILE* stream);
!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":3}],[{\"line\":1,\"ch\":0},{\"line\":1,\"ch\":3}],[{\"line\":0,\"ch\":4},{\"line\":0,\"ch\":9}],[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":3}],[{\"line\":1,\"ch\":0},{\"line\":1,\"ch\":3}],[{\"line\":0,\"ch\":17},{\"line\":0,\"ch\":21}],[{\"line\":1,\"ch\":34},{\"line\":1,\"ch\":38}],[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":3}],[{\"line\":1,\"ch\":0},{\"line\":1,\"ch\":3}],[{\"line\":1,\"ch\":4},{\"line\":1,\"ch\":9}],[{\"line\":1,\"ch\":10},{\"line\":1,\"ch\":20}],[{\"line\":1,\"ch\":23},{\"line\":1,\"ch\":29}],[{\"line\":0,\"ch\":17},{\"line\":0,\"ch\":21}],[{\"line\":1,\"ch\":34},{\"line\":1,\"ch\":38}]]"}
!@%STYLE%@!
Compare the compact fputc and fputs interfaces that operate on FILE* without exposing the stream representation. section 8.3.1



