I made Foo and Bar mutually recursive as in the following:
Foo.chs
{-# LANGUAGE ForeignFunctionInterface #-}
#include "foo.h"
module Foo where
-- Imports here
{#import Bar #}
data Foo = Foo
{ bar :: BarPtr
}
{#pointer *foo as FooPtr -> Foo #}
{#pointer *_foo as FooPtr -> Foo nocode #}
Bar.chs
{-# LANGUAGE ForeignFunctionInterface #-}
#include "bar.h"
module Bar where
-- Imports here
{#import Foo #}
data Bar = Bar
{ foo :: FooPtr
}
{#pointer *bar as BarPtr -> Bar #}
{#pointer *_bar as BarPtr -> Bar nocode #}
However, it seems there is no way to process two mutually recursive c2hs files. c2hs complains when I pass these two c2hs files as inputs:
$ c2hs Foo.chs Bar.chs
There must be exactly one binding file (suffix .chs),
and optionally one or more header files (suffix .h).
Try the option `--help' on its own for more information.
I would like to create a separate c2hs file for each C header file for the ease of maintenance. But what if there are looping struct declarations?
I made
Foo
andBar
mutually recursive as in the following:However, it seems there is no way to process two mutually recursive c2hs files. c2hs complains when I pass these two c2hs files as inputs: