preprocessor: submodule update
parent
776792e15c
commit
5994321cd7
|
@ -10313,7 +10313,7 @@ directives are:
|
|||
* ``@#includepath``, paths to search for files that are to be included,
|
||||
* ``@#include``, for file inclusion,
|
||||
* ``@#define``, for defining a macro processor variable,
|
||||
* ``@#if, @#ifdef, @#ifndef, @#else, @#endif`` for conditional statements,
|
||||
* ``@#if, @#ifdef, @#ifndef, @#elseif, @#else, @#endif`` for conditional statements,
|
||||
* ``@#for, @#endfor`` for constructing loops.
|
||||
|
||||
The macro processor maintains its own list of variables (distinct from model
|
||||
|
@ -10629,20 +10629,29 @@ Macro directives
|
|||
.. macrodir:: @#if MACRO_EXPRESSION
|
||||
@#ifdef MACRO_VARIABLE
|
||||
@#ifndef MACRO_VARIABLE
|
||||
@#elseif MACRO_EXPRESSION
|
||||
@#else
|
||||
@#endif
|
||||
|
||||
|br| Conditional inclusion of some part of the ``.mod`` file. The lines
|
||||
between ``@#if``, ``@#ifdef``, or ``@#ifndef`` and the next ``@#else`` or
|
||||
``@#endif`` is executed only if the condition evaluates to ``true``. The
|
||||
``@#else`` branch is optional and, if present, is only evaluated if the
|
||||
condition evaluates to ``false``.
|
||||
between ``@#if``, ``@#ifdef``, or ``@#ifndef`` and the next ``@#elseif``,
|
||||
``@#else`` or ``@#endif`` is executed only if the condition evaluates to
|
||||
``true``. Following the ``@#if`` body, you can zero or more ``@#elseif``
|
||||
branches. An ``@#elseif`` condition is only evaluated if the preceding
|
||||
``@#if`` or ``@#elseif`` condition evaluated to ``false``. The ``@#else``
|
||||
branch is optional and is only evaluated if all ``@#if`` and ``@#elseif``
|
||||
statements evaluate to false.
|
||||
|
||||
Note that when using ``@#ifdef``, the condition will evaluate to ``true``
|
||||
if the MACRO_VARIABLE has been previously defined, regardless of its
|
||||
value. Conversely, ``@#ifndef`` will evaluate to true if the MACRO_VARIABLE
|
||||
has not yet been defined.
|
||||
|
||||
Note that when using ``@#elseif`` you can check whether or not a variable
|
||||
has been defined by using the ``defined`` operator. Hence, to enter the
|
||||
body of an ``@#elseif`` branch if the variable ``X`` has not been defined,
|
||||
you would write: ``@#elseif !defined(X)``.
|
||||
|
||||
Note that if a real appears as the result of the MACRO_EXPRESSION, it
|
||||
will be interpreted as a boolean; a value of ``0`` is interpreted as ``false``,
|
||||
otherwise it is interpreted as ``true``. Further note that because of the
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 75b000a0b5f36893e2d32d97abcfe17bc1a3f71b
|
||||
Subproject commit 588896b5091ddee650a9548088a2df164df5c22b
|
|
@ -95,9 +95,9 @@ e = 0;
|
|||
u = 0;
|
||||
end;
|
||||
|
||||
@#define DEFINED=0
|
||||
@#define DEFINEDvar=0
|
||||
|
||||
@#ifndef DEFINED
|
||||
@#ifndef DEFINEDvar
|
||||
@#error "IFNDEF PROBLEM"
|
||||
@#else
|
||||
shocks;
|
||||
|
@ -107,12 +107,24 @@ var e, u = phi*0.009*0.009;
|
|||
end;
|
||||
@#endif
|
||||
|
||||
@#ifdef DEFINED
|
||||
@#ifdef DEFINEDvar
|
||||
stoch_simul;
|
||||
@#elseif true
|
||||
@#error "ELSEIF PROBLEM"
|
||||
@#else
|
||||
@#error "IFDEF PROBLEM"
|
||||
@#endif
|
||||
|
||||
@#if false
|
||||
@#error "IF ERROR"
|
||||
@#elseif false
|
||||
@#error "ELSEIF ERROR"
|
||||
@#elseif defined(DEFINEDvar)
|
||||
@#echo "Good"
|
||||
@#else
|
||||
@#error "ELSE ERROR"
|
||||
@#endif
|
||||
|
||||
@#define a = 1
|
||||
@#define f(x) = x + a
|
||||
@#define a = 2
|
||||
|
|
Loading…
Reference in New Issue