[Haskell-cafe] Why am I not allowed to use CStringLen in foreign export?

Andreas Marth Andreas-Haskell at gmx.net
Fri Sep 15 12:07:36 EDT 2006


I try to export a Haskell function to VBA. (At the moment without COM.)
Because VBA seems to expect a String with length information I tried to
return a CStringLen as defined in Foreign.C.String.
But if I try to compile it I get an "unacceptable argument type in foreign
declaration: CStringLen".
My reduced test program now is a strange "Hallo world!" program:

>module Test where
>import Foreign.C.String
>foreign export stdcall hello :: IO CStringLen
>hello :: IO CStringLen
>hello = do    newCStringLen ("Hallo world!")

Do I do some thing wrong here? (If I use CString instead of CStringLen and
accordingly newCString instead of newCStringLen everything compiles fine but
VBA crashes.)

Any help is appreciated,

More information about the Haskell-Cafe mailing list