digitalmars.D.bugs - [Issue 23357] New: ImportC: compatible types with definitions leads
- d-bugmail puremagic.com (52/52) Sep 22 2022 https://issues.dlang.org/show_bug.cgi?id=23357
https://issues.dlang.org/show_bug.cgi?id=23357 Issue ID: 23357 Summary: ImportC: compatible types with definitions leads to redeclaration error when used from D. Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: ImportC Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: dave287091 gmail.com Follow up to 22674, which seems to only be fixed for for opaque types. Repeating the example, but with the struct having a definition: Consider the following files: // foo_def.h typedef struct Foo *FooRef; struct Foo { int x; }; // maker.h #include "foo_def.h" FooRef make_foo(void); // freer.h #include "foo_def.h" void free_foo(FooRef foo); Which then preprocesses to: // maker.i typedef struct Foo *FooRef; struct Foo { int x; }; FooRef make_foo(void); // freer.i typedef struct Foo *FooRef; struct Foo { // freer.i(2): Error: struct `freer.Foo` already exists at maker.i(2). Perhaps in another function with the same name? int x; }; void free_foo(FooRef foo); You then try to use it in your D program: // use_foo.d import maker; import freer; void do_foo(){ FooRef f = make_foo(); free_foo(f); } --
Sep 22 2022