From 8f426b974a38d141205cac182d1883e1ecf8c9ce Mon Sep 17 00:00:00 2001 From: Araq Date: Fri, 17 Feb 2017 18:03:56 +0100 Subject: new feature: .used pragma to suppress declared-but-not-used warning --- doc/manual/pragmas.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'doc') 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 ------------------- -- cgit 1.4.1-2-gfad0