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

Using Pre-Processor Directives for Debugging

You read previously that you can build a debug or production version of an application by using pre-processor directives to selectively execute debug features. This is different from selective compilation but requires that you use selective compilation with pre-processor directives to prevent multiple inclusion.

The idea is that users can invoke the debug code by introducing a flag on the command line, say "-debug", for example. This needs several stages to achieve the end result: You need to define a flag that is global to the whole project, define a debug flag to test against, and provide conditional execution statements to invoke the debug code.

The first two stages are easy—you introduce a static ...

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