Api Design For C -

: Keep internal implementation details hidden from the user by using opaque pointers (e.g., typedef struct my_object my_object_t; ). This allows you to change the struct's definition without breaking the binary compatibility of client code.

: Avoid global variables within your library. Instead, pass a "context" or "handle" pointer to every function that needs to maintain state, which also helps with thread safety. Recommended Resources for Deep Dives API Design for C

: Since C has a flat namespace, use consistent prefixes for all public functions and types (e.g., libname_create_context() ) to avoid naming collisions with other libraries. : Keep internal implementation details hidden from the

: While Martin Reddy's API Design for C++ is a classic, its principles regarding stability, documentation, and testing are highly applicable to C as well. For C-specific patterns, " C Interfaces and Implementations " by David Hanson is a definitive guide. Instead, pass a "context" or "handle" pointer to

: Study the headers of widely used C libraries like libgeos or MATLAB's C API to see how they handle stability and cross-language compatibility.