小编Gar*_*s16的帖子

尝试将Haskell函数导出到C时,元组“无法在外来呼叫中编组”

我试图Foreign.C.Types在Haskell中使用C调用Haskell,但它在编译器中始终显示此错误:

  * Unacceptable argument type in foreign declaration:
        `(CInt, CInt)' cannot be marshalled in a foreign call
    * When checking declaration:
        foreign export ccall "func_hs" func_hs :: (CInt, CInt) -> CInt
   |
15 | foreign export ccall func_hs :: (CInt, CInt) -> CInt
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Run Code Online (Sandbox Code Playgroud)

GHCi版本8.6.3编译的确切代码:

{-# LANGUAGE ForeignFunctionInterface #-}

module Func where

import Foreign.C.Types

verify_hp :: (CInt, CInt) -> CInt

verify_hp (hp, maxHp) = if hp < maxHp then hp + 10 else maxHp

func_hs :: (CInt, …
Run Code Online (Sandbox Code Playgroud)

c haskell

3
推荐指数
1
解决办法
76
查看次数

标签 统计

c ×1

haskell ×1