« Return to Thread: HDBC with SQL Server / OBDC

Re: HDBC with SQL Server / OBDC

by Olivier Boudry :: Rate this Message:

Reply to Author | View in Thread

On Sun, May 25, 2008 at 8:04 PM, Andrew Appleyard <andrew.appleyard@...> 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.


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@...
http://www.haskell.org/mailman/listinfo/haskell-cafe

 « Return to Thread: HDBC with SQL Server / OBDC