So, we have seen two instances of using the preprocessor effectively: for #include files and limiting redundant processing of #include files. The last simple and effective use for the preprocessor is as a tool for debugging large and/or complex programs of multiple files.
Using the conditional directives, we can easily control what source code is inserted into the source file or excluded from the source file. Consider the following directives:
...
#if TEST_CODE
// code to be inserted and executed in final program
fprintf( stderr, "This is a test. We got here.\n" );
#endif
...
If the TEST_CODE macro is defined and has a nonzero value, the statements within the #if and #endif directives will be included in the source file. For this code to be included, we can define the macro in a couple of ways. First, it can be defined in the main source file with the following code:
#define TEST_CODE 1
This statement...