2012-10-20 51 views
2

我有一個使用FFI綁定到C函數的模塊。我怎樣才能讓這個模塊使用doctestHaskell doctest和FFI

運行doctest Foo.hs當我得到的錯誤是這樣的:

ByteCodeLink: can't find label 
During interactive linking, GHCi couldn't find the following symbol: 
    bar 
This may be due to you not asking GHCi to load extra object files, 
archives or DLLs needed by your current session. Restart GHCi, specifying 
the missing library using the -L/path/to/object/dir and -lmissinglibname 
flags, or simply by naming the relevant files on the GHCi command line. 
Alternatively, this link failure might indicate a bug in GHCi. 
If you suspect the latter, please send a bug report to: 
    [email protected] 

### Failure in Foo.hs:41: expression `foo' 
expected: [42] 
but got: 
      <interactive>:24:1: Not in scope: `bar' 
Examples: 2 Tried: 2 Errors: 0 Failures: 1 
+1

根據doctest文檔,你可以通過它任何你喜歡的GHC標誌。您是否嘗試過按照錯誤中的說明進行操作?如果你想得到更具體的幫助,你必須展示我們的代碼 - 足以讓我們重現你的問題。 –

回答

2

文檔測試接受任意GHC的標誌。如果你想運行帶有FFI代碼的Doctest,你需要傳遞完全相同的標誌,你需要用該代碼運行GHCi會話。例如,看看Doctest driver of unix-time