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