digitalmars.D.bugs - [Issue 23363] New: ImportC: Enums contain wrong members
- d-bugmail puremagic.com (47/47) Sep 23 2022 https://issues.dlang.org/show_bug.cgi?id=23363
https://issues.dlang.org/show_bug.cgi?id=23363 Issue ID: 23363 Summary: ImportC: Enums contain wrong members Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Keywords: ImportC Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: kipthemudkip yahoo.com It appears enum types from ImportC modules don't pick up members from the actual type, but take them from global #defines who knows where. To see what I mean, create a similar setup: //git2.c #include <git2.h> //test.d import git2; alias DumpModuleEnums(alias someModule) = () { static foreach (memberName; __traits(allMembers, someModule)) {{ alias member = __traits(getMember, git2, memberName); static if (is(member == enum)) { pragma(msg, memberName); static foreach (enumMemberName; __traits(allMembers, member)) { pragma(msg, " ", enumMemberName); } } }} }; alias dumpGit2 = DumpModuleEnums!git2; On my x64 Linux Mint machine, many of the enums look like: git_status_opt_t P_ALL P_PID P_PGID What are these mysterious members? They seem to be taken from /usr/include/linux/wait.h: /* First argument to waitid: */ #define P_ALL 0 #define P_PID 1 #define P_PGID 2 #define P_PIDFD 3 Very bizarre!! --
Sep 23 2022