liveBook · Manning

Chapter 10: Organization and documentation

What you will learn in chapter 10 of Modern C, Third Edition

This introduction explains why useful documentation distinguishes an interface’s purpose from its implementation details and why code and comments should each contribute meaningful information.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction explains why useful documentation distinguishes an interface’s purpose from its implementation details and why code and comments should each contribute meaningful information.

Key terms: magic constants, comments, function name, variable name, what, what for, how, in which manner, function interfaces, interface comments

10.1 Interface documentation

The section explains how to document C interfaces with Doxygen-style comments and organize related interfaces in cohesive header files.

Key terms: interface, Doxygen, @param, @a, @brief, strong semantic connections, header file, interfaces, include guards

10.2 Implementation

The section explains how clear implementation makes code readable, control flow obvious, and non-obvious ideas worth documenting.

Key terms: Implement literally, descriptive text, naming entities, control flow, compound statements, buried jumps, flyspeck expressions, pure functions, interface

10.2.1 Macros

This section explains how to use macros without hiding control flow or making function-like invocations behave unexpectedly.

Key terms: macros, control flow, dangling else, ERRORCHECK, function-like macros, do-while(false), compound statement, trailing semicolons, comma operators, continuable expressions

10.2.2 Pure functions

This section explains pure, value-based functions and uses rational-number arithmetic to show both their usefulness and their limits.

Key terms: passed by value, parameters, global variables, pure function, return value, abstract state machine, rat, numerator, denominator, sign

10.2.3 Attributes

This section explains how C23 attributes annotate code for compilers and tools, how to check attribute support, and how to avoid macro interference in headers.

Key terms: [[__unsequenced__]], pure, pointer parameters, pointer returns, deprecated, fallthrough, maybe_unused, nodiscard, noreturn, prefixed attributes

10.3 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 9: Style Chapter 11: Pointers →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.