Bug 24201 – ImportC: enum in .di file should have members un-namespaced.
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-10-25T05:56:52Z
Last change time
2023-10-27T01:48:09Z
Keywords
ImportC
Assigned to
No Owner
Creator
dave287091
Comments
Comment #0 by dave287091 — 2023-10-25T05:56:52Z
If you have a C file like:
// enum.c
enum Foo {
FOO_0,
FOO_1,
FOO_2,
};
which you convert to a .di file, it will contain (macro enums removed for brevity):
extern (C)
{
enum Foo
{
FOO_0,
FOO_1,
FOO_2,
}
}
Which is an incorrect translation. The imported C file will allow you to access the members of Foo without name spacing, like `FOO_0`, while the .di file will require you to write `Foo.FOO_0`. The enum members should be aliased into the module scope so that both imports function the same way. That is important as you might generate a .di file so your editor auto-complete works, but you want to compile with the actual .c file in case the code you are compiling against changes.
Comment #1 by bugzilla — 2023-10-27T01:48:09Z
*** This issue has been marked as a duplicate of issue 24121 ***