liveBook · Manning

Chapter 19: Variations in control flow

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

Introduces basic blocks and structured control flow, then explains why less predictable changes in control flow make program state harder to reason about.

After this chapter you will be able to

What it builds on

Section by section

Introduction

Introduces basic blocks and structured control flow, then explains why less predictable changes in control flow make program state harder to reason about.

Key terms: control flow, basic block, function calls, structured programs, basic blocks, syntactical nesting, abstract state, longjmp, interrupts, threads

19.1 A detailed example

Introduces a compact recursive descent parser that replaces nested braces with indentation and explains the main control flow of its descend function.

Key terms: basic_blocks, recursive descent parser, nesting, indentation, descend, switch, ASCEND, dp[0], recursion depth

19.2 Sequencing

This section explains which evaluations C orders, which it leaves unordered, and why defined programs can still produce different results.

Key terms: unsequenced, function arguments, sequence points, sequenced before, indeterminately sequenced, defined behavior, side effects, initialization list expressions, operands, assignment

19.3 Short jumps

This section contrasts local-object lifetimes in loops and goto-based repetition, then explains when a short jump is justified.

Key terms: goto, labels, compound literal, lifetime, while, exceptional changes in control flow, local cleanup, NEW_LINE, ASCEND

19.4 Functions

The section explains how recursive calls to descend have separate local objects while pointer arguments can expose shared state, and why restoring a pointed-to value matters to optimization.

Key terms: recursive functions, local object, program state, buffer, dp, pointer, unsigned argument, dp[0], restrict-qualified, longjmp

19.5 Long jumps

The section explains how setjmp and longjmp handle exceptional parser conditions by jumping across function calls, along with the validity, syntax, optimization, and type constraints involved.

Key terms: longjmp, descend, basic_blocks, setjmp, jmp_buf, condition argument, jmpTarget, controlling expressions, switch statement, volatile

19.6 Signal handlers

This section explains how C signal handlers respond to externally triggered events, why their work must be limited, and how a program can handle the event safely after normal execution resumes.

Key terms: hardware interrupts, synchronous signals, software interrupts, asynchronous signals, signal handlers, signal number, disposition, SIG_DFL, SIG_IGN, signal

19.7 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 18: Type-generic programming Chapter 20: Threads →

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.