Bug 22842 – importC: cannot declare function with a typedef
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-03-03T18:01:05Z
Last change time
2022-03-08T19:19:40Z
Keywords
ImportC, pull, rejects-valid
Assigned to
No Owner
Creator
Iain Buclaw
Comments
Comment #0 by ibuclaw — 2022-03-03T18:01:05Z
Declaring functions has two equivalent syntaxes.
---
int fun();
---
typedef int (tfunc)();
tfunc fun;
---
The latter is however rejected by the compiler.
Related code results in "Error: function 'fun' conflicts with variable 'fun'"
---
typedef int (myfunc)();
static myfunc fun;
int main()
{
return fun();
}
int fun() // inherits "static" from declaration.
{
return 0;
}
Comment #1 by bugzilla — 2022-03-05T06:10:12Z
Even worse:
typedef int (myfunc)();
myfunc fun;
fails with "Error: variable `test.fun` cannot be declared to be a function"
Comment #2 by dlang-bot — 2022-03-08T05:31:15Z
@WalterBright created dlang/dmd pull request #13778 "fix Issue 22842 - importC: cannot declare function with a typedef" fixing this issue:
- fix Issue 22842 - importC: cannot declare function with a typedef
https://github.com/dlang/dmd/pull/13778
Comment #3 by dlang-bot — 2022-03-08T19:19:40Z
dlang/dmd pull request #13778 "fix Issue 22842 - importC: cannot declare function with a typedef" was merged into master:
- 01bd25e33d604216879b58602749f2886cac1048 by Walter Bright:
fix Issue 22842 - importC: cannot declare function with a typedef
https://github.com/dlang/dmd/pull/13778