Bug 22757 – importC: typedef causes forward reference error

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-02-10T10:59:02Z
Last change time
2022-02-13T08:00:37Z
Keywords
ImportC, pull, rejects-valid
Assigned to
No Owner
Creator
dave287091

Comments

Comment #0 by dave287091 — 2022-02-10T10:59:02Z
The following reduced C code from sqlite fails to compile: typedef struct RowSet RowSet; struct RowSetChunk { struct RowSetChunk *pNextChunk; }; struct RowSet { struct RowSetChunk *pChunk; }; void foo(struct RowSet *pRowSet){ struct RowSetChunk **ppPrevTree = &pRowSet->pChunk; // Error: forward reference to `(*pRowSet).pChunk` } Oddly, if you remove the typedef it compiles without error, even though the typedef is not used at all. If you move the typedef, it also compiles without error.
Comment #1 by dlang-bot — 2022-02-13T06:55:52Z
@WalterBright created dlang/dmd pull request #13648 "fix Issue 22757 - importC: typedef causes forward reference error" fixing this issue: - fix Issue 22757 - importC: typedef causes forward reference error https://github.com/dlang/dmd/pull/13648
Comment #2 by dlang-bot — 2022-02-13T08:00:37Z
dlang/dmd pull request #13648 "fix Issue 22757 - importC: typedef causes forward reference error" was merged into master: - 48111109c9a2101f35f53c0dc8f1d100eb30625e by Walter Bright: fix Issue 22757 - importC: typedef causes forward reference error https://github.com/dlang/dmd/pull/13648