[Haskell-cafe] FFI and Excel VBA
cyril.schmidt at gmail.com
Thu Jun 21 02:59:27 EDT 2007
A while ago I built a Haskell DLL that had to be invoked from Excel.
For some reason (I do not remember exactly why) it did not work directly,
so I wrote a small wrapper DLL in C++ that invoked Haskell functions.
The wrapper DLL was invoked by Excel via COM.
As regards your example, the only thing that springs to my mind is:
check that the calling convention is set correctly (that is, to stdcall
instead of ccall).
2007/6/19, Lewis-Sandy, Darrell <darrelll at amgen.com>:
> I have finally gotten to the point where my dll compiles (there is a missing
> space in the mainDll.h code at line 4:12) using GHC 6.6.1, and used the
> declare statement to expose the "adder" function in Excel VBA. My VBA Code
> is given below:
> Private Declare Function adder Lib " adder.dll" Alias "adder at 8" (ByVal x As
> Integer, ByVal y As Integer) As Integer
> Private Sub test()
> Debug.Print adder(1, 2)
> End Sub
> My problem is this:
> The function works fine (the immediate window displays 3), but when I
> terminate Excel, I get an application error ("The instruction at …
> referenced memory at … . The memory could not be read."). Does anyone else
> have any experience calling Haskell from VBA that might be relevant?
More information about the Haskell-Cafe