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!!
Comment #1 by kipthemudkip — 2022-09-24T04:06:39Z
Sorry - doing a bit of compiler debugging, those values seem to come from /usr/include/x86_64-linux-gnu/bits/waitflags.h:
typedef enum
{
P_ALL, /* Wait for any child. */
P_PID, /* Wait for specified process. */
P_PGID /* Wait for members of process group. */
} idtype_t;
And it appears all enums affected by this issue are ones declared afterward as the form:
typedef enum {
//members
} some_enum_name;
I think more accurately, all enums declared this way are piggybacking off of the enums of the first one.
Comment #2 by dkorpel — 2022-09-29T14:17:08Z
Can you please reduce it to a stand alone test case and be more specific about the expected and actual output?
From your second comment, there's this definition:
```
typedef enum
{
P_ALL, /* Wait for any child. */
P_PID, /* Wait for specified process. */
P_PGID /* Wait for members of process group. */
} idtype_t;
```
And in your first comment you said the output looks like this:
```
git_status_opt_t
P_ALL
P_PID
P_PGID
```
I don't see "wrong members" here.
Comment #3 by bugzilla — 2023-04-09T06:09:24Z
Closing for lack of information. Refile with a reproducible test case.