Conditional compilation |
Top Previous Next |
Introduction
The conditional compilation directives allow sections of code to be selectively included for or excluded from compilation depending on whether the programmer-specified symbol (name) is defined or not. It is usually used as a portability tool for tailoring the program code to different hardware variants or to build multiple versions of an application with different functionality.
Another common use of conditional compilation is for temporarily omitting code. This is often done during testing and debugging when the programmer is experimenting with suspected areas of code. Although code may also be omitted by commenting its out, this approach does not work if the code already contains comments because such comments cannot be nested.
A conditional compilation name can either be defined with the #DEFINE directive or it can be defined in the Project Settings. Both defining a name by using the #DEFINE directive or by doing it from the Project Settings have the same effect, but the latter is a more user-friendly approach that does not require modification or even access to the VPL source code itself (encrypted include file).
A conditional compilation name consists of up to 80 letters and numbers.
The following shows some examples of the usage of conditional compilation:
Example 1
Example 2
Example 3
Example 4
Example 5
|