|
In the
past week or so I've been playing with HDirect to interface Hugs with some
statistical packages and have encountered a problem with HDirects support for
reference arguments of type double* or float*.
Specifically I have a function with prototype
void
cumnor( double* arg, double* result, double* ccum);
which
I wanted to interface to hugs/GHC using the following IDL
specification:
>
stub_include("cdflib.h")
> module Cdlib { >
> [pure]void cumnor
> ( [in]double* arg, > [out]double* result, > [out]double* ccum ); > > }; giving a function cumnor :: Double ->
(Double, Double) in Haskell.
When
compiled using IHC this worked fine for GHC-4.03, however it returned
gobbledegook in Hugs.
In the
end I've tracked this down to a problem in the construction of the support DLL
AddrBits.dll as supplied in the Win32 precompiled version of HaskellDirect
0.15.
To fix
the problem, I needed to supply the obvious header file for AddrBitsPrim.c and
include it in the AddrBits.idl file by adding
>
stub_include("AddrBitsPrim.h")
to the
start of that file.
Now I
recompiled using the makefile default compiler flags to generate AddrBits.c from
AddrBits.idl and compile both AddrBits.c and AddrBitsPrim.c to object code.
Finally I linked this all into a DLL using:
>
dllwrap -mno-cygwin --target=i386-mingw32 --def HugsMod.def AddrBits.dll_o
AddrBitsPrim.dll_o -o AddrBits.dll
This
new dll seems to have solved my problem completely.
Please
note: It was not enough to simply recompile AddrBits.dll, the c compiler
(egcs-2.91.66) definately requires the extra help the header file
provided.
All
the Very Best (and congratualtions on HDirect)
Dr.
Dominic Verity
Director
Categorical Solutions Pty Ltd
Uncertainty Management and Strategy.
Suite
405, 71 Archer Street,
Chatswood, NSW 2067,
Australia.
email: [EMAIL PROTECTED]
Visit our web site at:
"Viewpoints" is Categorical Solutions
complimentary newsletter delivered to your desktop via email. You can subscribe
to "Viewpoints" by clicking on the link below and entering your e-mail
address in the Subscribe panel on the side bar.
http://www.categoricalsolutions.com.au
|
- RE: *** HDirect Hugs support problem *** Dominic Verity
- RE: *** HDirect Hugs support problem *** Sigbjorn Finne (Intl Vendor)
