18. The C Preprocessor

Furthermore, lam of the opinion that Cpp must he destroyed.

Cato the Elder (Marcus Porcius Cato)

Problems with the C preprocessor, Cpp — alternatives to Cpp constructs — banning Cpp.

18.1 Cpp

Among the facilities, techniques, and ideas C++ inherited from C was the C preprocessor, Cpp. I didn’t like Cpp at all, and I still don’t like it. The character and file orientation of the preprocessor is fundamentally at odds with a programming language designed around the notions of scopes, types, and interfaces. For example, consider this innocent-looking code fragment:

#include<stdio.h>extern double sqrt(double);main(){    printf("The square root of 2 is %g\n",sqrt(2));    fflush(stdout);    return(0); ...

Get The Design and Evolution of C++, First 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.