[Haskell-cafe] Problem using #define in .hsc files

John Van Enk vanenkj at gmail.com
Mon Mar 30 09:20:11 EDT 2009


In Scurry, I select the CALLCONV on the CPP command line. This might be
better if it's the only place you need an #ifdef.
http://hackage.haskell.org/packages/archive/Scurry/0.0.3/Scurry.cabal

See the OS selection in the executable section:

executable scurry

[..]

    if os(mingw32)
        c-sources:          src/C/help-win.c
        extra-libraries:    Iphlpapi, ws2_32
        cc-options:         -D MINGW32
        cpp-options:        -DCALLCONV=stdcall

    if os(linux)
        build-depends: unix >= 2.3.0.0
        c-sources:          src/C/help-linux.c
        cc-options:         -D LINUX
        cpp-options:        -DCALLCONV=ccall


/jve


On Mon, Mar 30, 2009 at 4:41 AM, Alistair Bayley <alistair at abayley.org>wrote:

> 2009/3/29 Johan Tibell <johan.tibell at gmail.com>:
> >
> > foreign import CALLCONV unsafe "send"
> >    c_send :: CInt -> Ptr a -> CSize -> CInt -> IO CInt
> >
> > Compiling results in:
> >
> > parse error on input `CALLCONV'
>
>
> This is what we use in Takusen's Database.ODBC.OdbcFunctions.hsc:
>
> #ifdef mingw32_HOST_OS
> #let CALLCONV = "stdcall"
> #else
> #let CALLCONV = "ccall"
> #endif
>
> foreign import #{CALLCONV} unsafe "sql.h SQLAllocHandle" sqlAllocHandle ::
>  SqlHandleType -> Handle -> Ptr Handle -> IO SqlReturn
>
> Alistair
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090330/559c6dba/attachment.htm


More information about the Haskell-Cafe mailing list