[Issue 24280] New: ImportC: forward reference error when compiling multiple files
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Dec 12 22:46:34 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24280
Issue ID: 24280
Summary: ImportC: forward reference error when compiling
multiple files
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dkorpel at live.nl
I have two single-file c libraries, and dmd can compile either one just fine,
but not at the same time. Reduced example:
a.c:
```C
struct timespec
{
int s;
};
```
b.c:
```C
struct S;
struct timespec
{
int s;
};
typedef struct timespec Clock;
Clock now()
{
Clock result;
return result;
}
struct S
{
Clock clock;
};
```
```
dmd a.c // works
dmd b.c // works
dmd b.c a.c // works
dmd a.c b.c // fails:
b.c(13): Error: forward reference to type `timespec`
```
It's very fragile, sometimes the error goes away when removing a random unused
macro `#define _POSIX_C_SOURCE 200112L` or changing an identifier name (I can't
rename `timespec`), but it does seem deterministic: I get the error every time
as long as the input stays the same.
--
More information about the Digitalmars-d-bugs
mailing list