nim-lang / c2nim

c2nim is a tool to translate Ansi C code to Nim. The output is human-readable Nim code that is meant to be tweaked by hand before and after the translation process.
MIT License
509 stars 63 forks source link

Implicit Forward Declared Struct incorrectly Converted #275

Open miguelmartin75 opened 11 months ago

miguelmartin75 commented 11 months ago

For example:

foo.h:

typedef struct FooImpl* Foo;

Should output

discard "forward decl of FooImpl"
type Foo* = ptr FooImpl

However, instead c2nim outputs:

type Foo* = ptr FooImpl

If you attempt to import foo, Nim will complain about FooImpl not being declared.

One can get around this via forward declaring on a separate line in the header file, i.e. the C header should look as follows:

struct FooImpl;
typedef struct FooImpl* Foo;
miguelmartin75 commented 11 months ago

Never mind, in both cases, this does not work. I'm not sure how to deal with private/Opaque structs.

Apologies for the noise.