Merge pull request #4445 from Jeff-Ciesielski/jeffc/define_assignments
Add the ability to pass a value with the -d flag
This commit is contained in:
commit
689d3f75cf
11 changed files with 74 additions and 9 deletions
|
|
@ -1011,3 +1011,30 @@ debugging:
|
|||
|
||||
# ... complex code here that produces crashes ...
|
||||
|
||||
compile time define pragmas
|
||||
---------------------------
|
||||
|
||||
The pragmas listed here can be used to optionally accept values from
|
||||
the -d/--define option at compile time.
|
||||
|
||||
The implementation currently provides the following possible options (various
|
||||
others may be added later).
|
||||
|
||||
=============== ============================================
|
||||
pragma description
|
||||
=============== ============================================
|
||||
intdefine Reads in a build-time define as an integer
|
||||
strdefine Reads in a build-time define as a string
|
||||
=============== ============================================
|
||||
|
||||
.. code-block:: nim
|
||||
const FooBar {.intdefine.}: int = 5
|
||||
echo FooBar
|
||||
|
||||
.. code-block:: bash
|
||||
nim c -d:FooBar=42 foobar.c
|
||||
|
||||
In the above example, providing the -d flag causes the symbol
|
||||
``FooBar`` to be overwritten at compile time, printing out 42. If the
|
||||
``-d:FooBar=42`` were to be omitted, the default value of 5 would be
|
||||
used.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue