When using c2hs, you can use the inline header commands to define global variables:<br><br>
------------------------------------------------------------------------------------------------------<br>#c<br>const int HSMYLIBRARY_SOME_VAR = C_MY_VAR;<br>const char *HSMYLIBRARY_OTHER_VAR = C_OTHER_VAR;<br>#endc<br>
------------------------------------------------------------------------------------------------------<br><br>And then just bind them with foreign imports like any other variable:<br><br>------------------------------------------------------------------------------------------------------<br>foreign import ccall "HSMYLIBRARY_SOME_VAR" someVar :: CInt<br><br>foreign import ccall "HSMYLIBRARY_OTHER_VAR" otherVarPtr :: Ptr CChar<br><br>otherVar :: String<br>otherVar = unsafePerformIO (peekCString otherVarPtr)<br>
------------------------------------------------------------------------------------------------------