From 32cf926ef874fd8c162de72af5a14597dab484b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Thu, 16 Jun 2022 16:51:50 +0200 Subject: [PATCH] =?UTF-8?q?Macro-variables=20defined=20without=20a=20value?= =?UTF-8?q?=20are=20now=20set=20to=20=E2=80=9Ctrue=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They were previously set to 1. Ref. preprocessor#43 --- doc/manual/source/running-dynare.rst | 7 ++++--- doc/manual/source/the-model-file.rst | 2 +- preprocessor | 2 +- tests/macro_processor/example1_macro.mod | 7 ++++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/doc/manual/source/running-dynare.rst b/doc/manual/source/running-dynare.rst index be6d0aa3c6..5d89cf6ff3 100644 --- a/doc/manual/source/running-dynare.rst +++ b/doc/manual/source/running-dynare.rst @@ -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>> diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index 33a811a551..63ddf0f212 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -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 diff --git a/preprocessor b/preprocessor index 2a68f5a3af..41b1e89756 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 2a68f5a3af2886ce40149b1af10a9c08d5b4099c +Subproject commit 41b1e897569763c6688894597b7cab0cbb14a83d diff --git a/tests/macro_processor/example1_macro.mod b/tests/macro_processor/example1_macro.mod index 45ad345c4c..a0bd796c5c 100644 --- a/tests/macro_processor/example1_macro.mod +++ b/tests/macro_processor/example1_macro.mod @@ -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" -- GitLab