EmbeddedRelated.com
Books

C Interfaces and Implementations: Techniques for Creating Reusable Software (Addison-Wesley Professional Computing Serie

Hanson, David ● 1996

creating reusable software modules; they are the building blocks of large, reliable applications. Unlike some modern object-oriented languages, C provides little linguistic support or motivation for creating reusable application programming interfaces (APIs). While most C programmers use APIs and the libraries that implement them in almost every application they write, relatively few programmers create and disseminate new, widely applicable APIs. C Interfaces and Implementations shows how to create reusable APIs using interface-based design, a language-independent methodology that separates interfaces from their implementations. This methodology is explained by example. The author describes in detail 24 interfaces and their implementations, providing the reader with a thorough understanding of this design approach. Features of C Interfaces and Implementations: * Concise interface descriptions that comprise a reference manual for programmers interested in using the interfaces. * A guided tour of the code that implements each chapters interface tp help those modifying or extending an interface or designing related interfaces. * In-depth focus on algorithm engineering: how to packag


Why Read This Book

You will learn how to design C APIs that are clear, robust, and reusable across projects and platforms, using a language-independent interface-based methodology. The book gives concrete, production-tested patterns and full implementations so you can apply the techniques immediately to firmware, libraries, and embedded system code.

Who Will Benefit

Experienced C developers and embedded/firmware engineers who need to design modular, maintainable APIs and reusable libraries for constrained or cross-platform systems.

Level: Advanced — Prerequisites: Solid C programming (pointers, structs, function pointers), familiarity with build/link processes (make, static/shared libs), and basic data structures and debugging tools.

Get This Book

Key Takeaways

  • Design clean C interfaces that separate API from implementation and minimize coupling
  • Implement opaque types, handle-based modules, and encapsulation idioms suitable for C
  • Apply consistent ownership and memory-management conventions to avoid leaks and bugs
  • Build reusable container, iterator, and callback-based modules with clear contracts
  • Package, document, and version C libraries for reuse across projects and platforms
  • Adapt API and implementation choices to embedded constraints (size, performance, portability)

Topics Covered

  1. Introduction: Why interfaces matter in C
  2. Principles of interface-based design
  3. Header-file conventions and public/private separation
  4. Opaque types, handles, and encapsulation idioms
  5. Memory management and ownership policies
  6. Iterators, callbacks, and traversal patterns
  7. Common reusable modules: stacks, queues, lists, tables, sets, and maps
  8. Generic programming techniques and macro-based abstraction
  9. Error handling, assertions, and defensive programming
  10. Testing, debugging, and documenting interfaces
  11. Packaging, linking, and versioning reusable libraries
  12. Case studies: 24 interfaces and their implementations
  13. Appendices: style, portability, and migration strategies

Languages, Platforms & Tools

CPortable POSIX/UnixEmbedded targets (ARM Cortex-M, RISC-V and other microcontrollers)General-purpose systems (Linux)GCC/clangmake and build systemsLinkers (static/shared libraries)Debuggers (gdb)Text-based documentation and header tooling

How It Compares

Compared with K&R's The C Programming Language (which teaches core syntax and idioms), Hanson's book focuses specifically on API design and reusable-module implementations; compared to books like "Design Patterns in C", it emphasizes concrete, fully worked C implementations and practical packaging for real projects.

Related Books

Bryant, Randal, O'Hallaron,...