Macro-variables defined without a value are now set to “true”

They were previously set to 1.

Ref. preprocessor#43
mr#2067
Sébastien Villemot 2022-06-16 16:51:50 +02:00
parent ec6ce95efd
commit 32cf926ef8
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
4 changed files with 12 additions and 6 deletions

View File

@ -365,14 +365,15 @@ by the ``dynare`` command.
instead of ``psexec``, to properly allocate affinity when there are
more than 32 cores in the local machine. [default=true]
.. option:: -DMACRO_VARIABLE=MACRO_EXPRESSION
.. option:: -DMACRO_VARIABLE[=MACRO_EXPRESSION]
Defines a macro-variable from the command line (the same effect as
using the Macro directive ``@#define`` in a model file, see
:ref:`macro-proc-lang`). See the :ref:`note on quotes<quote-note>` for
info on passing a ``MACRO_EXPRESSION`` argument containing spaces. Note
that an expression passed on the command line can reference variables
defined before it.
defined before it. If ``MACRO_EXPRESSION`` is omitted, the variable is
assigned the ``true`` logical value.
*Example*
@ -380,7 +381,7 @@ by the ``dynare`` command.
.. code-block:: matlab
>> dynare <<modfile.mod>> -DA=true '-DB="A string with space"' -DC=[1,2,3] '-DD=[ i in C when i > 1 ]'
>> dynare <<modfile.mod>> -DA=true '-DB="A string with space"' -DC=[1,2,3] '-DD=[ i in C when i > 1 ]' -DE
.. option:: -I<<path>>

View File

@ -14278,7 +14278,7 @@ Macro directives
::
@#define var // Equals 1
@#define var // Equals true
@#define x = 5 // Real
@#define y = "US" // String
@#define v = [ 1, 2, 4 ] // Real array

@ -1 +1 @@
Subproject commit 2a68f5a3af2886ce40149b1af10a9c08d5b4099c
Subproject commit 41b1e897569763c6688894597b7cab0cbb14a83d

View File

@ -103,7 +103,12 @@ e = 0;
u = 0;
end;
@#define DEFINEDvar=0
@#define DEFINEDvar
// See preprocessor#43
@#if !(DEFINEDvar == true)
@#error "A variable defined without a value should be equal to logical true"
@#endif
@#ifndef DEFINEDvar
@#error "IFNDEF PROBLEM"