David Zeuthen has written a long and detailed article on many of the design issues that are faced when trying to write a plain C API. He deals with aspects such as library initialization, multithreading, error handling, versioning, and testing. It’s well worth a read if you are interested in writing a library in plain C (rather than C++). David’s collection of best practices is split into 5 parts, as follows:
- Part 1: Base libraries, Library init/shutdown, memory management, threads/processes
- Part 2: Event handling and the main loop, sync/async I/O
- Part 3: Modularity, namespaces, error handling, OO design
- Part 4: Helpers, daemons, and testing
- Part 5: API Design, documentation, and versioning
Comments are closed.