Oct 16

Conditional printf debug statements in C based programming languages

One of the first things people learn to do when learning to program is how to write an ‘Hello World’ application. For many programming languages this involves writing the iconic sentence to a console window. Its amazing how the same fundamental concepts from the ‘Hello World’ application can extend into hardcore application debugging. At university we called this ‘printf debugging’. However in the real world, its important to remember that having too many unnecessary logging statements in production applications can impact performance. In compiled programming languages there are ways to automatically remove all ‘printf debugging’ statements. Here is how to do it on C, C++ and Objective C… Continue reading