diff options
Diffstat (limited to 'doc/manual/pragmas.txt')
-rw-r--r-- | doc/manual/pragmas.txt | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/doc/manual/pragmas.txt b/doc/manual/pragmas.txt index 2a276c2e7..d30c37ff7 100644 --- a/doc/manual/pragmas.txt +++ b/doc/manual/pragmas.txt @@ -503,6 +503,26 @@ identifier that can be used to enable or disable it: This is often better than disabling all warnings at once. +used pragma +----------- + +Nim produces a warning for symbols that are not exported and not used either. +The ``used`` pragma can be attached to a symbol to suppress this warning. This +is particularly useful when the symbol was generated by a macro: + +.. code-block:: nim + template implementArithOps(T) = + proc echoAdd(a, b: T) {.used.} = + echo a + b + proc echoSub(a, b: T) {.used.} = + echo a - b + + # no warning produced for the unused 'echoSub' + implementArithOps(int) + echoAdd 3, 5 + + + experimental pragma ------------------- @@ -1018,12 +1038,12 @@ 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 -=============== ============================================ +================= ============================================ +pragma description +================= ============================================ +`intdefine`:idx: Reads in a build-time define as an integer +`strdefine`:idx: Reads in a build-time define as a string +================= ============================================ .. code-block:: nim const FooBar {.intdefine.}: int = 5 |