I wrote an Erlang module where not all the internal functions are directly called. Instead, there's a couple functions that look something like this:
weird_func(Cmd, Args) ->
?MODULE:Cmd(Args).
It's a simplified example, but you get the idea. The Erlang compiler spits out warnings about unused functions, when in fact they are actually used, just not directly. Is there some way to suppress these warnings? Ideally I don't want to suppress all such warnings, but rather I'd like to tell the Erlang compiler to consider a few specific functions as special cases.
there is a compile option specifically for this :
http://www.erlang.org/doc/man/compile.html
so, for your example insert a directive like this :
-compile([{nowarn_unused_function, [{ wierd_function_1,Arity1 },
... ]}]).
but the above warning about the compiler silently discarding the functions still stands as far as i know.
It's not just a matter of suppressing the warning. An unexported function can't be called in the way you intend.
-module(foo).
-export([f/0]).
f() -> ?MODULE:g().
g() -> ok.
1> c(foo).
./foo.erl:4: Warning: function g/0 is unused
{ok,foo}
2> foo:f().
** exception error: undefined function foo:g/0
The compiler is free to drop the unused, unexported function completely. Simply export the function making it available call using the ?MODULE:F syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With