From 11730e6c3b468621258f99539284d75fecafe276 Mon Sep 17 00:00:00 2001 From: Jeff Ciesielski Date: Tue, 5 Jul 2016 09:06:40 -0400 Subject: [PATCH] Update documentation and news --- doc/basicopt.txt | 3 ++- doc/manual/pragmas.txt | 27 +++++++++++++++++++++++++++ doc/nimc.rst | 10 +++++++++- web/news/version_0_15_released.rst | 6 ++++++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/doc/basicopt.txt b/doc/basicopt.txt index c68d731e6..9a1cfd956 100644 --- a/doc/basicopt.txt +++ b/doc/basicopt.txt @@ -11,7 +11,8 @@ Arguments: arguments are passed to the program being run (if --run option is selected) Options: -p, --path:PATH add path to search paths - -d, --define:SYMBOL(:VAL) define a conditional symbol + -d, --define:SYMBOL(:VAL) + define a conditional symbol (Optionally: Define the value for that symbol) -u, --undef:SYMBOL undefine a conditional symbol -f, --forceBuild force rebuilding of all modules diff --git a/doc/manual/pragmas.txt b/doc/manual/pragmas.txt index 1a1f0b734..88ddabef8 100644 --- a/doc/manual/pragmas.txt +++ b/doc/manual/pragmas.txt @@ -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. diff --git a/doc/nimc.rst b/doc/nimc.rst index 48dbaeb21..eb1beb549 100644 --- a/doc/nimc.rst +++ b/doc/nimc.rst @@ -98,6 +98,11 @@ enable builds in release mode (``-d:release``) where certain safety checks are omitted for better performance. Another common use is the ``-d:ssl`` switch to activate `SSL sockets `_. +Additionally, you may pass a value along with the symbol: ``-d:x=y`` +which may be used in conjunction with the `compile time define +pragmas`_ +to override symbols during build time. + Configuration files ------------------- @@ -370,7 +375,10 @@ For example, to generate code for an `AVR`:idx: processor use this command:: For the ``standalone`` target one needs to provide a file ``panicoverride.nim``. See ``tests/manyloc/standalone/panicoverride.nim`` for an example -implementation. +implementation. Additionally, users should specify the +amount of heap space to use with the ``-d:StandaloneHeapSize=`` +command line switch. Note that the total heap size will be +`` * sizeof(float64)``. Nim for realtime systems diff --git a/web/news/version_0_15_released.rst b/web/news/version_0_15_released.rst index ecda59fcd..5c58e138b 100644 --- a/web/news/version_0_15_released.rst +++ b/web/news/version_0_15_released.rst @@ -38,8 +38,14 @@ Library Additions Compiler Additions ------------------ +- The ``-d/--define`` flag can now optionally take a value to be used + by code at compile time. + Language Additions ------------------ +- Added ``{.intdefine.}`` and ``{.strdefine.}`` macros to make use of + (optional) compile time defines. + Bugfixes --------