bind to abstract types for c struct with idris

柔情痞子 提交于 2021-02-11 12:20:24

问题


I can not find how to treat this typedef struct TF_Status TF_Status; as abstract types and bind to that

the c function is 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

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


回答1:


TF_Status* TF_NewStatus(); returns a pointer to a TF_Status when called. So you only need

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


来源:https://stackoverflow.com/questions/51242134/bind-to-abstract-types-for-c-struct-with-idris

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!