new feature: .used pragma to suppress declared-but-not-used warning
This commit is contained in:
parent
dd8cbf5fca
commit
8f426b974a
5 changed files with 51 additions and 10 deletions
|
|
@ -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
|
||||
-------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue