13 lines
755 B
HTML
13 lines
755 B
HTML
<p>
|
|
When programming, you will definitely run into situations, where you code something with the only purpose to help you debug.
|
|
You probably don't want those functions in the released program. A simple way to do this, is to wrap them in a macro, which gets defined
|
|
to nothing, if you didn't set the compiler flag for debug-mode (e.g -DDEBUG).
|
|
</p>
|
|
<p>
|
|
Another feature from the preproccessor you can use for debugging is the compile time information. With __FILE__ you get the filename and with __LINE__ the line number.
|
|
With that you can augment your debugging prints to include information about the file and line.
|
|
</p>
|
|
<p>
|
|
Define the debug() macro, that behaves like printf but only actually prints when the variable '-DDEBUG' is set.
|
|
</p>
|