Conditional Compiling

From Klaus' wiki
Jump to: navigation, search

Some times, when in development, it can be necessary to exclude or include parts of the source. Below I'll describe a simple way of handling this problem.

In general you can either in your makefile change the settings for how you code is compiled.

Or if using Eclipse in the properties for the project you can set or reset symbols.

In a makefile you can use something as shown below

# Comment/uncomment the following line to disable/enable debugging

In Eclipse the same can be set in Project->Properties as shown in the image below


Now you can prepare your source code to include or exclude parts when compiled with the DEBUG symbol set for the preprocessor.