[Issue 24201] New: ImportC: enum in .di file should have members un-namespaced.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 25 05:56:52 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24201
Issue ID: 24201
Summary: ImportC: enum in .di file should have members
un-namespaced.
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: ImportC
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dave287091 at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list