That would make more sense, since you can use the header to craft an interface in which some components are public and some are private.
That would make more sense, since you can use the header to craft an interface in which some components are public and some are private.
They called this "modular programming" where "classes" were represented by opaque pointers and actions could only be performed on those pointers using the functions defined in the module.
What's the benefit of "opaque" pointers?
For background, my C code is almost entirely on microcontrollers. So I'm looking at it from that point of view. If you're talking about event-based applications running inside a full operating system, I've always stepped up to something like C#, so I don't have much experience with function pointers for that kind of work.
But consider the position of developer who implements a shared library that is distributed in binary form only. In this case, the benefit of opaque pointers for the development of a library is that the implementation remains private at the source level. One could, of course, reverse-engineer the binary but few people would do it.
If you define your structures in a public header -- and this includes C++ classes and templates with private members -- one can easily see the implementation and, with a few casts, start munging the guts of your objects and baking in a hard requirement on a specific layout and / or version of your library.
But for dynamic linking, this is how you avoid breaking ABI while maintaining forward flexibility.
Yes that tracks with the work I've done. It could even be so simple that only one value needs to be exposed through a getter (along with a couple "methods").
An ADC in an embedded system could operate like that.
You can, in a defined way (i.e., no invoking of UB). I just didn't put that in.
Many of the newer languages have modules or packages, but interface well with C, thus give the benefits of what the article was referring to. To include that various newer ones don't use class-based OOP, just as C doesn't.
Clearly you can abstract away the parts of data that the API should not see.