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

Adding a Debug Flag

Debug information can be displayed on the screen, in a file, in a separate window, or through other reporting means. A computer that is starting up, for example, uses something called POST (power on self-test) and makes a series of beeps that tell the user which POST tests have been successfully executed.

Let’s assume that you want to supply a flag in the following format:

My_Program -debug

From here, you need to perform some actions to identify and process the flag:

  • Introduce a global runtime variable to contain the debug status.

  • Ensure that debug behavior statements are executed selectively.

  • Process the command line for the -debug flag.

These are very straightforward steps, with a few caveats that I’ll cover in Chapters 10 ...

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