Bug 22734 – importC: typedef anonymous enum members not available when used from D

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-02-03T22:25:49Z
Last change time
2022-02-07T08:44:17Z
Keywords
ImportC, pull, rejects-valid
Assigned to
No Owner
Creator
dave287091

Comments

Comment #0 by dave287091 — 2022-02-03T22:25:49Z
With the following C file: // enu.c enum E_a { A, }; enum { B, }; typedef enum { C, } E_c; typedef enum E_d { D, } E_d; int a = A; int b = B; int c = C; int d = D; Which is then imported by the following D file: // use_enu.d import enu; auto d_a = A; auto d_b = B; auto d_c = C; auto d_d = D; You get the following errors: enu.c(19): Error: undefined identifier `C` use_enu.d(6): Error: undefined identifier `C` What is odd though is that if you compile enu.c directly: dmd enu.c -c You get no error, it is when you compile a D file dmd use_enu.d -c that you get the above errors.
Comment #1 by dave287091 — 2022-02-03T22:29:12Z
In fact, you get the error in the C file even if you are not using the enum in your D file.
Comment #2 by dlang-bot — 2022-02-04T08:14:13Z
@WalterBright created dlang/dmd pull request #13610 "fix Issue 22734 - importC: typedef anonymous enum members not availab…" fixing this issue: - fix Issue 22734 - importC: typedef anonymous enum members not available when used from D https://github.com/dlang/dmd/pull/13610
Comment #3 by dlang-bot — 2022-02-07T08:44:17Z
dlang/dmd pull request #13610 "fix Issue 22734 - importC: typedef anonymous enum members not availab…" was merged into master: - 3403a6e386423aa824a983bb13e01c1e096346ae by Walter Bright: fix Issue 22734 - importC: typedef anonymous enum members not available when used from D https://github.com/dlang/dmd/pull/13610