[Issue 24042] New: ImportC: Error: no definition for static 'function'
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jul 9 19:57:23 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24042
Issue ID: 24042
Summary: ImportC: Error: no definition for static 'function'
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: ibuclaw at gdcproject.org
```
// cfile.c
static int staticfunc() { return 0; }
// dmodule.d
import cfile;
int main() { return staticfunc(); }
```
Compiler IMO correctly issues an error
---
Error: no definition for static staticfunc
---
However, besides the obvious lack of source file/line information, it looks
like the error occurs (in the back-end) because the symbol is missing from
compilation, rather than just disallowing the referencing of C static symbols
from D.
Even if both D and C sources are compiled in the same CU, I find it
questionable to allow referencing C static symbols from D. But that can be
debated out here.
For reference, this is where in dmd backend the error comes from.
```
// In backend/cgen.d
if (f.sym.Sseg == UNKNOWN)
{
printf("Error: no definition for static %s\n", prettyident(f.sym));
// no definition found for static
err_exit(); // BUG: do better
}
```
--
More information about the Digitalmars-d-bugs
mailing list