scope of header files

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Thu Mar 6 22:04:46 EST 2008


On Thu, 2008-03-06 at 04:50 -0800, John Meacham wrote:
> On Thu, Mar 06, 2008 at 12:41:56PM +0000, Duncan Coutts wrote:
> > c2hs has to read the header files on your system to be able to check any
> > consistency.
> > 
> > I'm not sure why hsc2hs is the minimal tool. It relies on a C compiler
> > where c2hs does not. What happens with Haskell implementations that do
> > not bundle a C compiler (eg ghc in future on win32)?
> 
> Hmm... I am not quite sure how c2hs works then. like, how can it figure
> out the offsets of fields in data structures without knowing the field
> layout algorithm for a given architecture/os combo without invoking a c
> compiler?

It's calculated directly.

> Though, if there were a way to figure that stuff out without a c
> compiler in a portable way, that would be cool.

It is specified by the platform C ABI. So it varies from one platform to
another, but it is specified for most platforms, that's what allows you
to link code compiled by different C compilers and have it work.

Duncan



More information about the Glasgow-haskell-users mailing list