Re:Object oriented programming in C (2007)
by theyregreat on Sunday October 22, 2017 @06:01PM
(#15529198)
Yup. Pointers to functions and call equivalence of functions and pointers to functions are that in C. Prototype interfaces (ie plugins) are trivially had with a struct containing pointers to such common API functions. The plugin just needs an init function that returns a pointer to such a const structure, and you’re in business.
Another popular trick is to use opaque structs for private data contained in the public struct in the header. Then, the private code defines the private struct. It’s not perfect information hiding but it separates what is intended public and what is intended to be private.
Another popular trick is to use opaque structs for private data contained in the public struct in the header. Then, the private code defines the private struct. It’s not perfect information hiding but it separates what is intended public and what is intended to be private.