[Haskell-cafe] C variable access via FFI

Tom Hawkins tomahawkins at gmail.com
Tue Apr 20 02:48:16 EDT 2010

I have a bunch of global variables in C I would like to directly read
and write from Haskell.  Is this possible with FFI, or must I write a
bunch of C wrapper functions for the interface, i.e. a 'get' and a
'set' for each variable?

I'm building a simulator for one of our embedded systems.  The C is
embedded code for an ECU -- the global variables are sensor and
control IO.  I'm using Haskell to integrate the C with vehicle models
and to provide the user interface.  With the help of the SDL hackage
lib, I'm able to feed analog and discrete inputs from a gamepad into
the simulator, which then runs the embedded code and streams VCD data
into GTKWave, providing waveform visualization in realtime.  Pretty
fun stuff.


More information about the Haskell-Cafe mailing list