Conditional Compiling
Conditional compiling uses definitions as conditions. Below is the main syntax:
#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?
Languages | Description |
---|---|
ST and IL | Directives must be entered alone on one line
of text |
FBD | Directives must be entered as the text of network breaks |
FFLD |
Directives must be entered as a network pragma with the icon. In the example below, if CONDITION has been defined using #define syntax, then the networks 2 to 4 are included in the code, else the networks 5 to 12 are included.
|
-
-
Conditional compilation do not apply to actions in an SFC"Sequential function chart" It can be used to program processes that can be split into steps. The main components of SFC are: - Steps with associated actions - Transitions with associated logic conditions - Directed links between steps and transitions 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