Bug 22343 – importC: Error: 'undefined identifier' with implicit declaration of function

Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-09-28T17:49:52Z
Last change time
2021-10-08T09:37:32Z
Keywords
ImportC, rejects-valid
Assigned to
No Owner
Creator
Iain Buclaw
See also
https://issues.dlang.org/show_bug.cgi?id=22342, https://issues.dlang.org/show_bug.cgi?id=22344

Comments

Comment #0 by ibuclaw — 2021-09-28T17:49:52Z
Similar to issue 22342, functions can be implicitly declared in C11, and will have default function type `int(...)`. --- int main() { func(12); func("12"); func(1.2); return 0; }
Comment #1 by ibuclaw — 2021-09-29T08:05:43Z
(In reply to Iain Buclaw from comment #0) > Similar to issue 22342, functions can be implicitly declared in C11, and > will have default function type `int(...)`. On the C side, the type is really `int()`, but not specifying any parameters is the same as accepting any parameters.
Comment #2 by bugzilla — 2021-10-07T00:26:12Z
Although implicit function declarations used to be Standard, they are not as of C99. They are still allowed by clang and gcc, but: cc -c test.c -std=c99 -pedantic-errors will correctly yield: error: implicit declaration of function `func` Implicit function declarations are a terrible, bug-prone feature that has been outlawed for over 20 years. Note that clang at least warns on it. Some discussion: https://stackoverflow.com/questions/9182763/implicit-function-declarations-in-c/9182835
Comment #3 by bugzilla — 2021-10-07T00:40:00Z