diff options
author | Araq <rumpf_a@web.de> | 2017-02-17 18:03:56 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-02-17 18:03:56 +0100 |
commit | 8f426b974a38d141205cac182d1883e1ecf8c9ce (patch) | |
tree | 0ab2d29435251472a0fdcf26e8580ff104f0c84f /doc | |
parent | dd8cbf5fca7becf43b5cec07ecf7e579308e2e7a (diff) | |
download | Nim-8f426b974a38d141205cac182d1883e1ecf8c9ce.tar.gz |
new feature: .used pragma to suppress declared-but-not-used warning
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 ------------------- |