Technical data

Compiler Directives
2-13
Target Language Expressions
In any place throughout a target file, you can include an expression of the form
%<expression>. The Compiler replaces expression with a calculated
replacement value based upon its type. Integer constant expressions are folded
and replaced with the resultant value; string constants are concatenated (e.g.,
two strings in a row
"a" "b" are replaced with "ab").
%<expression> /* Evaluates the expression.
* Operators include most standard C
* operations on scalars. Array indexing
* is required for certain parameters that
* are block-scoped within the .rtw file.*/
Within the context of an expression, each identifier must evaluate to a
parameter or function argument currently in scope.
You can use the
%< > directive on any line to perform textual substitution. To
include the
> character within a replacement, you must escape it with a “\
character as in:
%<x \> 1 ? "ABC" : "123">
Note: It is not necessary to place expressions in the %< > format when they
appear on directive lines.
Table 2-3 lists the operators that are allowed in expressions. In this table,
expressions are listed in order from highest to lowest precedence. The
horizontal lines distinguish the order of operations.
As opposed to C expressions, conditional operators are not short-circuited.
Therefore, if the expression includes a function call with side effects, the effects
are noticed as if the entire expression was evaluated.
In the Target Language Compiler, you cannot depend on short-circuit
evaluation to avoid errors such as:
%if EXISTS(foo) && foo == 3