绑定到具有idris的c结构的抽象类型

时间:2018-07-09 09:23:31

标签: ffi idris

我找不到如何将此typedef struct TF_Status TF_Status;视为抽象类型并绑定到该

c函数为TF_Status* TF_NewStatus();

data TF_Status
tfNewStatus : IO TF_Status 
tfNewStatus = foreign FFI_C "TF_NewStatus" (IO TF_Status)

http://docs.idris-lang.org/en/latest/reference/ffi.html

它抱怨When checking argument fty to function foreign: Can't find a value of type FTy FFI_C [] (IO TF_Status)

1 个答案:

答案 0 :(得分:1)

TF_Status* TF_NewStatus();在被调用时返回指向TF_Status的指针。所以你只需要

tfNewStatus : IO Ptr 
tfNewStatus = foreign FFI_C "TF_NewStatus" (IO Ptr)