Which are the main advantages and disadvantages of me using opaque pointers for all my structures? I have been thinking about using this approach and here are some trivial thoughts that I have:Trivial advantages: structure implementation is hidden, requiring who uses my modules to use only available implemented functions (creating using factories and signatures of manage/change the data in the struct).Trivial disadvantages: structure fields cannot be accessed directly implying the need of implementing all sorts of functions to retrieve the values and only the ones the developer wants.So the main advantage seems to be also my main disadvantage?Is there any better approach to archive lower coupling and higher cohesion between the usage of structures in my C modules? 
C programming - Advantages and disadvantages of using opaque pointers for structure handling
c
One major disadvantage: using an opaque pointer prevents you from allocating the structures from the stack. Thus, if you have one function call where you need a structure for the duration of the call but don't need it after the function has returned, you are still forced to use malloc() for the structure.Don't do that! malloc() is much, much slower than stack allocation. Not only that, but also malloc() is prone to memory leaks. If you instead define the structure in the header file, you can allocate the structure from the stack for the example case.Of course, having the structure in the header file allows misusing it by breaking the abstraction. So, it is your responsibility to define functions operating on the structure and make sure that everybody consistently uses only those functions and not direct member access.For this reason, I almost always define structures in header files. I also define functions operating on the structure, initializer/finalizer functions, and a STRUCTURE_INIT preprocessor macro that can be used instead of a function call to initialize the structure (if feasible).Also, if the structure is defined in a header file, you can use static inline functions. They are much faster than real function calls, while not having the downsides of preprocessor macros.