[Haskell-cafe] HDBC with SQL Server / OBDC

Olivier Boudry olivier.boudry at gmail.com
Tue May 27 10:46:46 EDT 2008


On Sun, May 25, 2008 at 8:04 PM, Andrew Appleyard <
andrew.appleyard at gmail.com> wrote:

> I had the same problem last week.  I found that GHCi would silently crash,
> but GHC would give link errors on the foreign imported functions from the
> odbc32 library.  Changing the calling convention from 'ccall' to 'stdcall'
> for the 16 'sql.h' imports fixed the problem for me, but I'm not convinced
> that's the 'right way' to fix it (ccall is surely the appropriate calling
> convention for using ODBC on Unix, for example).


If the calling convention is stdcall on Windows and ccall on other OS then
it should be defined based on the OS. This can be done by updating the .hsc
files to define the calling convention as a "macro" depending on the OS
type.

#ifdef mingw32_HOST_OS
#let CALLCONV = "stdcall"
#else
#let CALLCONV = "ccall"
#endif

And the foreign import should use CALLCONV instead of ccall.

This should make it work on Windows and not break it on Linux.

Olivier.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080527/d383753f/attachment.htm


More information about the Haskell-Cafe mailing list