Table of Contents

Copyright

Brief Table of Contents

Table of Contents

Acknowledgments

About this book

About the cover illustration

Level 0. Encounter

Chapter 1. Getting started

1.1. Imperative programming

1.2. Compiling and running

Summary

Chapter 2. The principal structure of a program

2.1. Grammar

2.2. Declarations

2.3. Definitions

2.4. Statements

2.4.1. Iteration

2.4.2. Function calls

2.4.3. Function return

Summary

Level 1. Acquaintance

Chapter 3. Everything is about control

3.1. Conditional execution

3.2. Iterations

3.3. Multiple selection

Summary

Chapter 4. Expressing computations

4.1. Arithmetic

4.1.1. +, -, and *

4.1.2. Division and remainder

4.2. Operators that modify objects

4.3. Boolean context

4.3.1. Comparison

4.3.2. Logic

4.4. The ternary or conditional operator

4.5. Evaluation order

Summary

Chapter 5. Basic values and data

5.1. The abstract state machine

5.1.1. Values

5.1.2. Types

5.1.3. Binary representation and the abstract state machine

5.1.4. Optimization

5.2. Basic types

5.3. Specifying values

5.3.1. Complex constants

5.4. Implicit conversions

5.5. Initializers

5.6. Named constants

5.6.1. Read-only objects

5.6.2. Enumerations

5.6.3. Macros

5.6.4. Compound literals

5.7. Binary representions

5.7.1. Unsigned integers

5.7.2. Bit sets and bitwise operators

5.7.3. Shift operators

5.7.4. Boolean values

5.7.5. Signed integers

5.7.6. Fixed-width integer types

5.7.7. Floating-point data

Summary

Chapter 6. Derived data types

6.1. Arrays

6.1.1. Array declaration

6.1.2. Array operations

6.1.3. Array length

6.1.4. Arrays as parameters

6.1.5. Strings are special

6.2. Pointers as opaque types

6.3. Structures

6.4. New names for types: type aliases

Summary

Chapter 7. Functions

7.1. Simple functions

7.2. main is special

7.3. Recursion

Summary

Chapter 8. C library functions

8.1. General properties of the C library and its functions

8.1.1. Headers

8.1.2. Interfaces

8.1.3. Error checking

8.1.4. Bounds-checking interfaces

8.1.5. Platform preconditions

8.2. Mathematics

8.3. Input, output, and file manipulation

8.3.1. Unformatted text output

8.3.2. Files and streams

8.3.3. Text IO

8.3.4. Formatted output

8.3.5. Unformatted text input

8.4. String processing and conversion

8.5. Time

8.6. Runtime environment settings

8.7. Program termination and assertions

Summary

Level 2. Cognition

Chapter 9. Style

9.1. Formatting

9.2. Naming

Summary

Chapter 10. Organization and documentation

10.1. Interface documentation

10.2. Implementation

10.2.1. Macros

10.2.2. Pure functions

Summary

Chapter 11. Pointers

11.1. Pointer operations

11.1.1. Address-of and object-of operators

11.1.2. Pointer addition

11.1.3. Pointer subtraction and difference

11.1.4. Pointer validity

11.1.5. Null pointers

11.2. Pointers and structures

11.3. Pointers and arrays

11.3.1. Array and pointer access are the same

11.3.2. Array and pointer parameters are the same

11.4. Function pointers

Summary

Chapter 12. The C memory model

12.1. A uniform memory model

12.2. Unions

12.3. Memory and state

12.4. Pointers to unspecific objects

12.5. Explicit conversions

12.6. Effective types

12.7. Alignment

Summary

Chapter 13. Storage

13.1. malloc and friends

13.1.1. A complete example with varying array size

13.1.2. Ensuring consistency of dynamic allocations

13.2. Storage duration, lifetime, and visibility

13.2.1. Static storage duration

13.2.2. Automatic storage duration

13.3. Digression: using objects "before” their definition

13.4. Initialization

13.5. Digression: a machine model

Summary

Chapter 14. More involved processing and IO

14.1. Text processing

14.2. Formatted input

14.3. Extended character sets

14.4. Binary streams

14.5. Error checking and cleanup

Summary

Level 3. Experience

Chapter 15. Performance

15.1. Inline functions

15.2. Using restrict qualifiers

15.3. Measurement and inspection

Summary

Chapter 16. Function-like macros

16.1. How function-like macros work

16.2. Argument checking

16.3. Accessing the calling context

16.4. Default arguments

16.5. Variable-length argument lists

16.5.1. Variadic macros

16.5.2. A detour: variadic functions

16.6. Type-generic programming

Summary

Chapter 17. Variations in control flow

17.1. A complicated example

17.2. Sequencing

17.3. Short jumps

17.4. Functions

17.5. Long jumps

17.6. Signal handlers

Summary

Chapter 18. Threads

18.1. Simple inter-thread control

18.2. Race-free initialization and destruction

18.3. Thread-local data

18.4. Critical data and critical sections

18.5. Communicating through condition variables

18.6. More sophisticated thread management

Summary

Chapter 19. Atomic access and memory consistency

19.1. The “happened before” relation

19.2. C library calls that provide synchronization

19.3. Sequential consistency

19.4. Other consistency models

Summary

 Takeaways

 Bibliography

Index

List of Figures

List of Tables

List of Listings