Conditional Compiling
- Conditional compiling directives condition the inclusion of a part of the program in the generated code based on pragma.
- Conditional compiling is an easy way to manage several various machine configurations and options in one unique application project.
- Conditional compiling uses definitions as conditions.
#ifdef CONDITION
statementsYES...
#else
statementsNO...
#endif
- If CONDITION has been defined using #define syntax, then the statementsYES part is included in the code, else the statementsNO part is included.
- The #else statement is optional.
-
-
Intellisense facilitates the reading by coloring in gray the part of the program which is not active.
How to define conditional compiling directives?
Language | Description |
---|---|
FBD Language |
Directives must be entered as the text of FBD Network Breaks |
FFLD Language |
Directives must be entered as a network pragma with the icon. In this example image:
|
IL Language ST Language |
-
-
Conditional compilation do not apply to actions in an SFC step.
The condition __DEBUG is automatically defined when the application is compiled in DEBUG mode.
This allows you to incorporate some additional statements (such as trace outputs) in your code that are not included in RELEASE mode.
#ifdef __DEBUG
Printf('In debug mode', 0, 0, 0, 0);
#endif
See Also