liveBook · Manning

Contract

As explained in Modern C, Third Edition

A library interface is the specified set of declarations and calling conventions through which software accesses library functionality.

A function interface specifies what a function does and the semantics callers can rely on. In the C library, clear interfaces help make everyday functionality usable portably and can separate compiler implementations from library implementations. section 8.0

Keep the contract distinct from implementation details:

  • The interface states what the function does; interface comments explain its purpose. section 10.0
  • Function code shows how the work is organized, while code comments describe implementation details. section 10.0

C headers typically hold interface specifications, while translation units hold implementations. Users can rely on the specification without needing to inspect how the function is implemented. section 10.0

Library functions

Functions such as printf, puts, and strtod provide everyday library functionality through defined interfaces and semantics. section 8.0

How Modern C, Third Edition covers it

How deep it goes
Distinguishes interface specification and purpose from code organization and implementation details.
Examples
Illustrates library interfaces with printf, puts, and strtod, and contrasts interface comments with implementation comments.
What you can do after
Understand which details belong in an interface specification versus implementation code and comments.
How it connects
Connects C library functions with APIs, headers, translation units, compilers, and library implementations.

Also explained in

Compare how 44 books explain contract →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.