5 code-generation compiler-errors ats
我正在尝试使用该funset_avltree库,但编译器生成无效的 C 代码。我正在使用 ATS/Postiats 版本 0.2.10。
我的代码相当简单:
(* ast.sats *)
staload "libats/SATS/funset_avltree.sats"
datatype ast =
| ast_var of string
fun free_vars (ast : ast) :<> set string
Run Code Online (Sandbox Code Playgroud)
(* ast.dats *)
#include "share/atspre_staload.hats"
staload "./ast.sats"
staload "libats/SATS/funset_avltree.sats"
dynload "libats/DATS/funset_avltree.dats"
implement free_vars (ast : ast) : set string =
case+ ast of
| ast_var name => funset_sing name
Run Code Online (Sandbox Code Playgroud)
然而,编译器的输出相当混乱:
ast_dats.c:359:51:警告:函数“S2EVar”的隐式声明无效
在 C99 中 [-Wimplicit-function-declaration]
ATSINSmove(tmpret0, PMVtmpltcstmat[0](funset_sing<S2EVar(4713)>)(tmp1)) ;
^
ast_dats.c:359:39:错误:使用未声明的标识符“funset_sing”
ATSINSmove(tmpret0, PMVtmpltcstmat[0](funset_sing<S2EVar(4713)>)(tmp1)) ;
^
ast_dats.c:359:64:错误:预期表达式
ATSINSmove(tmpret0, PMVtmpltcstmat[0](funset_sing<S2EVar(4713)>)(tmp1)) ;
^
funset我在和 时遇到类似的错误funset_listord。我一定错过了一些微不足道的事情。我是否需要包含某些内容或将某些标志传递给编译器?
根本原因是您没有静态加载库提供的 AVL 树模板。
在错误消息中,PMVtmpltcstmat通常表明模板有问题。通常的情况是程序员忘记包含模板,或者忘记提供模板变量。你是第一个案例。
请添加这一行,
staload _ = "libats/DATS/funset_avltree.dats"
Run Code Online (Sandbox Code Playgroud)
静态加载模板,并使它们可供编译器使用。请参阅此处的工作示例,https://glot.io/snippets/eiu6f3dd2r
此外,dynload当您有需要评估的“全局”值时,就需要它。就您而言,您不需要dynloadavl 树库。另外,在您自己的文件中ast.dats,没有这样的全局值。您可以定义
#define ATS_DYNLOADFLAG 0
Run Code Online (Sandbox Code Playgroud)
告诉编译器不要为ast.dats.
| 归档时间: |
|
| 查看次数: |
92 次 |
| 最近记录: |