erlang的dialyzer使用中遇到的问题,以及解决方法

dialyzer错误分析:
错误1: Callback info about the tcp_server_handler behaviour is not available


解决办法:
  在R15之后,自定义类型需要采用新的模式:


例子:


%% User-defined behaviour module
-module(simple_server).
-export([start_link/2,...]).


-callback init(State :: term()) -> 'ok'.
-callback handle_req(Req :: term(), State :: term()) -> {'ok', Reply :: term()}.
-callback terminate() -> 'ok'.


%% Alternatively you may define:
%%
%% -export([behaviour_info/1]).
%% behaviour_info(callbacks) ->
%%     [{init,1},
%%      {handle_req,2},
%%      {terminate,0}].


start_link(Name, Module) ->
    proc_lib:start_link(?MODULE, init, [self(), Name, Module]).


init(Parent, Name, Module) ->
    register(Name, self()),
    ...,
    Dbg = sys:debug_options([]),
    proc_lib:init_ack(Parent, {ok, self()}),
    loop(Parent, Module, Deb, ...).


...
In a callback module:


-module(db).
-behaviour(simple_server).


-export([init/0, handle_req/2, terminate/0]).


错误2:Unknown types
  需要将自定义类型导出:


解决办法:
例子:
-type my_struct_type() :: Type.
-type orddict(Key, Val) :: [{Key, Val}].


-export_type([my_struct_type/0, orddict/2]).


错误3:Unknown functions
  如果是不是开源或者自己开发的库,可以通过 apps参数指定, apps参数还可以指定目录和文件
  例子:--apps $(APPS) ../base_lib ../open_lib/protobuffs ./ebin   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值