
Hello,
If -fvia-C fixes your problem, then your code has a bug, strictly speaking. If your foreign call requires some information from a header file, then the right way to call it is by making a small C wrapper function and calling that.
I tried to do this but couldn't. I could get GHC to compile and link with warnings of the form: Warning: resolving _my_fun@24 by linking to _my_fun But when I ran the executable, the system crashed at the point that a foreign function was called.
Bear in mind that we'll be deprecating -fvia-C in the future, and also that you might want your code to work in GHCi too, which doesn't read any header files when compiling foreign imports.
I am currently developing on a windows xp machine. After a week of fighting with FFI, I feel forced to conclude that FFI barely works with GHC (and seems to require -fvia-C) and doesn't work at all with GHCi (I think there is an unresolved bug about this). Am I wrong about the state of affairs for windows? thanks, Jeff