Bug 23887 – ImportC: extend enums to support longs

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-05-05T08:14:29Z
Last change time
2023-05-11T07:27:32Z
Keywords
ImportC
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=23884

Comments

Comment #0 by bugzilla — 2023-05-05T08:14:29Z
From Patrick Schluter: - enum constants bigger than uint. Full in undefined behaviour territory according to the standard, gcc defines the behaviour and defines enums as long/unsigned long/long long/unsigned long long if necessary. ImportC rejects for instance Error: enum member `lang.LANID_TYPE.LANID_GL` enum member value `4294967296LU` does not fit in an `int`
Comment #1 by bugzilla — 2023-05-11T07:27:32Z
This works: #include <stdio.h> enum E { A = 4294967296LU }; int main() { printf("%llu\n", A); return 0; } in the current master.