Bug 19461 – Function literals can't be extern(C)

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-12-03T10:20:55Z
Last change time
2018-12-03T14:51:12Z
Assigned to
No Owner
Creator
Atila Neves

Comments

Comment #0 by atila.neves — 2018-12-03T10:20:55Z
https://dlang.org/spec/expression.html#function_literals Unfortunately, they can't be extern(C), and if attempted there is no compiler or linker error to warn the user about the ABI incompatilibity. Using the parameters just won't work and there's no way to fix it. This shows up in, say, attempting to use function literals as the function pointer value for a Python extension implemented in D. An extern(C) function has to be written/generated just to fix the ABI of calling it.
Comment #1 by uplink.coder — 2018-12-03T12:58:54Z
If you could provide a small testcase, so I can have a better idea of what you mean, would be appreciated.
Comment #2 by atila.neves — 2018-12-03T14:51:12Z
I tried reducing it but couldn't. I'll close it since it'll be too hard to reproduce and I came up with a workaround.