Eduardo Habkost <ehabk...@redhat.com> writes: > On Fri, Nov 20, 2020 at 06:29:16AM +0100, Markus Armbruster wrote: [...] >> When the structure of a data type is to be kept away from its users, I >> prefer to keep it out of the public header, so the compiler enforces the >> encapsulation. > > I prefer that too, except that it is impossible when users of the > API need the compiler to know the struct size.
There are cases where the structure of a data type should be encapsulated, yet its size must be made known for performance (avoid dynamic memory allocation and pointer chasing). Need for encapsulation correlates with complex algorithms and data structures. The cost of dynamic allocation is often in the noise then.