Hi,
 
thanks for the report & fix - not having prototypes in scope
for functions taking or returning doubles is a bad idea.
 
The reason why you're not seeing the problem on the
ghc side is that it doesn't use AddrBits (it's only there
to make up for the rather incomplete implementation of
Addr that Hugs comes with.)
 
--sigbjorn
 
 -----Original Message-----
From: Dominic Verity [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 23, 1999 07:51
To: [EMAIL PROTECTED]
Subject: *** HDirect Hugs support problem ***



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.
 
 

Reply via email to