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
staticandexternkeywords. So this chapter takes some time to discuss linkage, and break down the confusing uses of thestatickeyword. -
The
constkeyword 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access