Bug 23143 – ImportC: forward enum declarations need to be supported

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-05-27T15:00:32Z
Last change time
2022-07-12T00:06:23Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
Max Samukha

Comments

Comment #0 by maxsamukha — 2022-05-27T15:00:32Z
Test case 1: enum _POOL_TYPE; enum _POOL_TYPE { NonPagedPool, NonPagedPoolExecute = NonPagedPool }; Error: `enum _POOL_TYPE` has no members Test case 2: typedef enum _POOL_TYPE POOL_TYPE; enum _POOL_TYPE { NonPagedPool, NonPagedPoolExecute = NonPagedPool }; Error: undefined identifier `NonPagedPool` Forward enum declarations are forbidden by C11. However, they are used in Windows SDK headers, and there are no workarounds that wouldn't involve additional preprocessing.
Comment #1 by maxsamukha — 2022-05-28T07:13:45Z
I'd rather qualify this as a bug. If ImportC can't handle system headers, it's a failure. This issue prevents Windows DDK's wdm.h from being imported.
Comment #2 by bugzilla — 2022-07-07T07:12:50Z
It seems both gcc and clang support it unless the -Wpedantic is supplied: fix23143> gcc -c test.c -std=c11 -Wpedantic test.c:3:6: warning: ISO C forbids forward references to âenumâ types [-Wpedantic] enum _POOL_TYPE; ^ fix23143> clang -c test.c -std=c11 -Wpedantic test.c:3:6: warning: ISO C forbids forward references to 'enum' types [-Wpedantic] enum _POOL_TYPE; ^ 1 warning generated. So I suppose we are doomed to support it.
Comment #3 by dlang-bot — 2022-07-09T05:24:27Z
@WalterBright created dlang/dmd pull request #14277 "fix Issue 23143 - ImportC: forward enum declarations need to be suppo…" fixing this issue: - fix Issue 23143 - ImportC: forward enum declarations need to be supported https://github.com/dlang/dmd/pull/14277
Comment #4 by dlang-bot — 2022-07-12T00:06:23Z
dlang/dmd pull request #14277 "fix Issue 23143 - ImportC: forward enum declarations need to be suppo…" was merged into master: - 65b5bbf146ec7dbd75603a9a9a0627f128cc8c7e by Walter Bright: fix Issue 23143 - ImportC: forward enum declarations need to be supported https://github.com/dlang/dmd/pull/14277