O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

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

Recap

You use the #define family to declare named values (constants), which can then be included in your C program or tested by the #ifdef and #ifndef directives. You can also use snippets of C code, known as macros, in the same way, but because the pre-processor has no knowledge of C coding rules, the compiler is left to catch any syntactic misuse.

You can also provide parameters to function-like macros, which act in the same way as regular functions in C. However, any parameters that are passed can be made type-independent, which gives you a distinct advantage, provided you can live with the inevitable downside associated with an increase in code complexity.

There are other pre-processor directives, but they are beyond the scope of this book. ...

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