Bug 22886 – ImportC: forward declaration of struct in a function prototype leads to redeclaration with different type error
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-03-17T08:27:44Z
Last change time
2022-03-22T08:31:10Z
Keywords
ImportC, pull, rejects-valid
Assigned to
No Owner
Creator
dave287091
Comments
Comment #0 by dave287091 — 2022-03-17T08:27:44Z
The following C code fails to compile:
// test.c
struct config *Configlist_add(int);
struct config *Configlist_add(int x){ // Error: function `test.Configlist_add` redeclaration with different type
return 0;
}
struct config {
int dot;
};
Strangely, if the function takes no arguments there is no error. If you forward declare the struct at the top of the file, there is no error.
Comment #1 by dave287091 — 2022-03-21T06:38:29Z
This also fails:
// test.c
struct config *Configlist_add(int);
struct config *Configlist_add(int); // Error: function `test.Configlist_add` redeclaration with different type
struct config {
int dot;
};
Comment #2 by dlang-bot — 2022-03-22T07:22:53Z
@WalterBright created dlang/dmd pull request #13859 "fix Issue 22886 - ImportC: forward declaration of struct in a functio…" fixing this issue:
- fix Issue 22886 - ImportC: forward declaration of struct in a function prototype leads to redeclaration with different type error
https://github.com/dlang/dmd/pull/13859
Comment #3 by dlang-bot — 2022-03-22T08:31:10Z
dlang/dmd pull request #13859 "fix Issue 22886 - ImportC: forward declaration of struct in a functio…" was merged into master:
- 23745f7a5fe4192389f502e81671655ce8278154 by Walter Bright:
fix Issue 22886 - ImportC: forward declaration of struct in a function prototype leads to redeclaration with different type error
https://github.com/dlang/dmd/pull/13859