[Issue 24718] New: [ImportC] typedef struct with name as a pointer cannot be used with struct name
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Aug 24 22:15:08 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24718
Issue ID: 24718
Summary: [ImportC] typedef struct with name as a pointer cannot
be used with struct name
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: ImportC
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: schveiguy at gmail.com
imported.c:
typedef struct Foo {
int x;
} *pFoo;
struct Bar {
struct Foo foo;
};
main.d:
import imported;
Compiling main.d fails to build with the following message:
imported.c(6): Error: variable `testimportc.Bar.foo` - no definition of struct
`Foo`
imported.c(6): see
https://dlang.org/spec/struct.html#opaque_struct_unions
imported.c(6): perhaps declare a variable with pointer type `Foo*`
instead
Actually compiling imported.c with the D compiler succeeds!
Note that it *requires* a typedef to a pointer, with a struct name. Removing
the pointer, it works. Removing the typedef, it works.
Note that I discovered this on a Mac via ldc, but I believe this is not limited
to those.
--
More information about the Digitalmars-d-bugs
mailing list