diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual/pragmas.txt | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/doc/manual/pragmas.txt b/doc/manual/pragmas.txt index af955a3e0..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 ------------------- |