Importing a reference to a non-function entity.

Simon Marlow simonmar@microsoft.com
Wed, 20 Feb 2002 13:28:15 -0000


> What is the politically correct way using the FFI and ghc5.03=20
> (which I have just managed to compile from
> CVS) to import an externally defined object (not a function)?=20
>  I have a source file containing the line
>=20
> foreign label "default_options" defaultOptions :: CString.CString
>=20
> for which ghc5.03 complains about "Warning: foreign=20
> declaration uses deprecated non-standard syntax",
> but which works anyway.  However in my attempt to be a good=20
> little ghc user, I try instead
>=20
> foreign import "default_options" defaultOptions :: CString.CString
>=20
> (after deciphering with difficulty the Postscript version of=20
> the FFI document on this screen) but
> still get the deprecated warning.  Then I try
>=20
> foreign import ccall "default_options" defaultOptions ::=20
> CString.CString

I believe you meant to say=20

  foreign import ccall "&default_options"=20
     defaultOptions :: CString.Cstring

:-)  (see the latest FFI addendum at =
http://www.cse.unsw.edu.au/~chak/haskell/ffi/)

Cheers,
	Simon