scope of header files

Duncan Coutts duncan.coutts at
Thu Mar 6 05:43:41 EST 2008

On Wed, 2008-03-05 at 18:46 -0800, John Meacham wrote:
> On Thu, Mar 06, 2008 at 02:18:08AM +0000, Duncan Coutts wrote:
> > There are rather too many of these C libs that define their public
> > interfaces as macros. I had to adjust the zlib binding the other day to
> > allow it to compile without -fvia-C. It now implements a couple macros
> > in the Haskell code. I hope zlib don't change their macro in the next
> > version.
> Yeah, I ran into the exact same issue with my curses binding. the
> solution was to use hsc2hs to create wrappers when needed.
> something like this:
> foreign import ccall "get_COLOR_PAIRS" colorPairsPtr :: Ptr CInt
> #def inline int * get_COLOR_PAIRS (void) {return &COLOR_PAIRS;}

The problem with that is that it doesn't follow the rules about scope of
header files either. Technically the little .h file that hsc2hs
generates for you needs to be installed and used by every client

> hsc2hs is needed anyway for portable C bindings so it isn't too onerous
> of a requirement.

Or c2hs! :-)


More information about the Glasgow-haskell-users mailing list