D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22537 - importC: Error: undefined reference to 'function' when using static in forward declaration
Summary: importC: Error: undefined reference to 'function' when using static in forwar...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 major
Assignee: No Owner
URL:
Keywords: ImportC, wrong-code
Depends on:
Blocks:
 
Reported: 2021-11-23 01:05 UTC by Iain Buclaw
Modified: 2022-09-21 21:54 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Iain Buclaw 2021-11-23 01:05:50 UTC
static int func();

int main()
{
  return func();
}

static int func()
{
  return 0;
}
Comment 1 Iain Buclaw 2021-11-23 01:06:33 UTC
Looking at the output of nm, you can see the function appears twice.

0000000000000000 t func
                 U func
0000000000000000 W main
Comment 2 Walter Bright 2021-12-10 10:20:47 UTC
Fixed by https://github.com/dlang/dmd/pull/13399
Comment 3 Andrea Fontana 2022-04-08 10:18:27 UTC
The same code using -lib won't work:

dmd file.c -lib

Error: no definition for static func
Comment 4 duser 2022-04-21 14:42:33 UTC
it works with -lib on stable v2.099.1 but not current git master

bisected it to https://github.com/dlang/dmd/pull/13846
Comment 5 Walter Bright 2022-09-21 21:45:47 UTC
Please don't reopen fixed bugs with different bugs. It makes the bug list unnecessarily hard to manage.
Comment 6 Walter Bright 2022-09-21 21:54:43 UTC
Closed and filed new issue https://issues.dlang.org/show_bug.cgi?id=23356