RE: Importing a reference to a non-function entity.

What is the politically correct way using the FFI and ghc5.03 (which I have just managed to compile from CVS) to import an externally defined object (not a function)? I have a source file containing the line
foreign label "default_options" defaultOptions :: CString.CString
for which ghc5.03 complains about "Warning: foreign declaration uses deprecated non-standard syntax", but which works anyway. However in my attempt to be a good little ghc user, I try instead
foreign import "default_options" defaultOptions :: CString.CString
(after deciphering with difficulty the Postscript version of the FFI document on this screen) but still get the deprecated warning. Then I try
foreign import ccall "default_options" defaultOptions :: CString.CString
I believe you meant to say foreign import ccall "&default_options" defaultOptions :: CString.Cstring :-) (see the latest FFI addendum at http://www.cse.unsw.edu.au/~chak/haskell/ffi/) Cheers, Simon

Simon Marlow wrote: [snip]
I believe you meant to say
foreign import ccall "&default_options" defaultOptions :: CString.Cstring
:-) (see the latest FFI addendum at http://www.cse.unsw.edu.au/~chak/haskell/ffi/) [snip]
Yes, it works, brilliant! And I can specify the C header file too, rather than having to hack it unreliably using a pragma at the top of the file.
participants (2)
-
George Russell
-
Simon Marlow