Issue 24201 - ImportC: enum in .di file should have members un-namespaced.
Summary: ImportC: enum in .di file should have members un-namespaced.
Status: RESOLVED DUPLICATE of issue 24121
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: ImportC
Depends on:
Blocks:
 
Reported: 2023-10-25 05:56 UTC by dave287091
Modified: 2023-10-27 01:48 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description dave287091 2023-10-25 05:56:52 UTC
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 Walter Bright 2023-10-27 01:48:09 UTC

*** This issue has been marked as a duplicate of issue 24121 ***