[Issue 24276] New: ImportC: typedef aliases not emitted correctly in .di files
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Dec 9 17:10:01 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24276
Issue ID: 24276
Summary: ImportC: typedef aliases not emitted correctly in .di
files
Product: D
Version: D2
Hardware: x86
OS: Mac OS X
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: mail at tomaskral.sk
Consider the following C file with a typedef alias:
// hmm.c
typedef union hmm_vec2
{
struct { float X, Y; };
float Elements[2];
} hmm_vec2;
typedef hmm_vec2 hmm_v2;
used in a D program:
// main.d
import hmm;
void main() {
hmm_v2 v2 = { X: 1, Y: 2 };
}
Compiling both files in a single pass, without emitting the .di file, i.e.:
$ dmd main.d hmm.c
works fine.
But doing it by generating hmm.o and hmm.di first, and then linking the
program, fails:
$ dmd -c hmm.c -Hf=hmm.di
$ dmd main.d hmm.o
hmm.di(13): Error: union `hmm.hmm_vec2` conflicts with union `hmm.hmm_vec2` at
hmm.di(4)
The emitted .di file looks like this:
extern (C)
{
union hmm_vec2
{
struct
{
float X = void;
float Y = void;
}
float[2] Elements = void;
}
union hmm_vec2;
...
The second union is incorrect; it should have been the typedef alias
alias hmm_v2 = hmm_vec2;
instead.
--
More information about the Digitalmars-d-bugs
mailing list