
"Bulat" == Bulat Ziganshin
writes:
Bulat> Hello Haskell, what is a best way to bring C constant (defined Bulat> in header file) into the Haskell source? Haskell project is Bulat> cabalized and should work with both Win and Unix while the Bulat> constants are OS-specific. the best way i found at this moment Bulat> is to use the following scheme: Bulat> mmap.h: Bulat> #if defined(mingw32_HOST_OS) || defined(__MINGW32__) || Bulat> defined(_MSC_VER) .... #else INLINE int const_MAP_FILE( void ) Bulat> { return MAP_FILE; Bulat> } Bulat> #endif Bulat> mmap.hs: Bulat> #if defined(mingw32_HOST_OS) || defined(__MINGW32__) || Bulat> defined(_MSC_VER) .... #else foreign import ccall unsafe Bulat> "mydefs.h const_MAP_FILE" mAP_FILE :: CInt #endif Well, the haskell source is processed with cpp, so if constants are #define'd (and not declared with `const') you can use preprocessor macros to generate Haskell code (yeh, I know it's silly, but why not?). -- WBR, Max Vasin. NP: Nothing playing right now