Conditional Compiling

From Klaus' wiki
Revision as of 07:51, 21 February 2014 by Klaus (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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
DEBUG = y

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

Snapshot1.png

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