Conditional Compiling
"Structured text"
A high-level language that is block structured and syntactically resembles Pascal, IL
"Instruction list"
This is a low-level language and resembles assembly,
FFLD, and FBD
"Function block diagram"
A function block diagram describes a function between input variables and output variables. A function is described as a set of elementary blocks languages. Conditional compiling directives condition the inclusion
of a part of the program in the generated code based on pragma
A compiler directive communicating additional "pragmatic" information.
Pragmas are processed at compile time, not at run time. They pass information to the compiler. 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. 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 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