O'Reilly logo

C++ Gotchas: Avoiding Common Problems in Coding and Design by Stephen C. Dewhurst

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. The Preprocessor

Preprocessing is probably the most dangerous phase of C++ translation. The preprocessor is concerned with tokens (the “words” of which the C++ source is composed) and is ignorant of the subtleties of the rest of the C++ language, both syntactic and semantic. In effect, the preprocessor doesn't know its own strength and, like many powerful ignoramuses, is capable of much damage.

The advice of this chapter is to allow the preprocessor to perform only tasks that require much power but little knowledge of C++ and to avoid its use for anything that requires finesse.

Gotcha #25: #define Literals

C++ programmers don't use #define to define literals, because in C++ such usage causes bugs and portability problems. Consider ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required