Importing a reference to a non-function entity.

George Russell ger@tzi.de
Tue, 19 Feb 2002 23:25:53 +0100


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

and praise be, the deprecated message goes away.  Only problem is, I now get a segmentation fault
when I run the code . . .