Support circular imports
- Dominant language
- Haskell
- Stars
- 211
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
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?
- foo.h
``` c
struct _bar;
typedef struct _foo {
struct _bar* b;
} foo;
```
- bar.h
``` c
struct _foo;
typedef struct _bar {
struct _foo* f;
} bar;
```
I made `Foo` and `Bar` mutually recursive as in the following:
- Foo.chs
``` haskell
{-# 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
``` haskell
{-# 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.
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.