[Haskell-cafe] C variable access via FFI
bertram.felgenhauer at googlemail.com
Tue Apr 20 06:13:07 EDT 2010
Tom Hawkins wrote:
> I have a bunch of global variables in C I would like to directly read
> and write from Haskell. Is this possible with FFI,
Yes it is, as explained in section 4.1.1. in the FFI specification .
An import for a global variable int bar would look like this:
foreign import ccall "&bar" bar :: Ptr CInt
The difference to an import of a function int foo() is the extra "&".
More information about the Haskell-Cafe