gpt4 book ai didi

erlang - 预处理器,ifdef

转载 作者:行者123 更新时间:2023-12-02 05:17:21 25 4
gpt4 key购买 nike

在调试gen_server模块的时候,我想记录更多的细节状态。

init()->
put(?COMPLETED_COMMANDS,[]),
-ifdef(DEBUG).
put(?DETAIL_STATUS,[]),
-endif.
ok.

编译器给出以下错误。

src/benvolio_command_cache.erl:34: syntax error before: ','
src/benvolio_command_cache.erl:36: syntax error before: '.'
src/benvolio_command_cache.erl:33: variable 'DEBUG' is unbound
src/benvolio_command_cache.erl:33: function ifdef/1 undefined

如何在*.erl文件的函数中添加调试代码行?

最佳答案

宏指令不能在函数内部使用。见8.5 Flow Control in Macros .

关于erlang - 预处理器,ifdef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14451506/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com