Chapter 8. Important C Syntax that Textbooks Often Do Not Cover

The last chapter covered some topics that traditional C textbooks stressed but which may not be relevant in a current computing environment. This chapter covers some points that I have found many textbooks do not cover or only mention in passing. Like the last chapter, this chapter covers a lot of little topics, but it breaks down into three main segments:

  • The preprocessor often gets short mention, I think because many people think of it as auxiliary or not real C. But it’s there for a reason: there are things that macros can do that the rest of the C language can’t. Not all standards-compliant compilers offer the same facilities, and the preprocessor is also how we determine and respond to the characteristics of the environment.

  • In my survey of C textbooks, I found a book or two that do not even mention the static and extern keywords. So this chapter takes some time to discuss linkage, and break down the confusing uses of the static keyword.

  • The const keyword fits this chapter because it is too useful to not use, but it has oddities in its specification in the standard and in its implementation in common compilers.

Cultivate Robust and Flourishing Macros

Some situations have common trap doors that users must know to avoid, but if you can provide a macro that always dodges the trap, you have a safer user interface. Chapter 10 will present several options for making the user interface to your library friendlier ...

Get 21st Century C, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.