【问题标题】:How to include file from Erlang/OTP module如何包含来自 Erlang/OTP 模块的文件
【发布时间】:2015-01-06 06:53:15
【问题描述】:

我需要包含一些来自 Erlang/OTP 模块的头文件,除了使用绝对路径,还有什么实用的方法吗

-include("/usr/lib64/erlang/lib/snmp-4.25/include/snmp_types.hrl").

【问题讨论】:

标签: erlang


【解决方案1】:

是的,请参考问题:Erlang: what is the difference between "include_lib" and "include"?

如果包含在其系统库中,则应使用-include_lib(XXX) 而不是-include(XXX)

【讨论】:

    【解决方案2】:

    我认为你可以使用:

    -include_lib("snmp/include/snmp_types.hrl").
    

    include_lib 类似于 include,但不应该指出一个 绝对文件。相反,第一个路径组件(可能在 变量替换)被假定为应用程序的名称。

    Example:
    
    -include_lib("kernel/include/file.hrl").
    
    The code server uses code:lib_dir(kernel) to find the directory of the current (latest) version of Kernel, and then the subdirectory
    

    include 搜索文件 file.hrl。

    【讨论】:

      猜你喜欢
      • 2020-12-27
      • 2014-01-19
      • 1970-01-01
      • 2011-06-20
      • 2020-01-11
      • 2014-12-10
      • 1970-01-01
      • 2017-04-10
      • 1970-01-01
      相关资源
      最近更新 更多