Bug 8108 – Forward declaration and implementation allowed in same file

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-05-16T01:12:00Z
Last change time
2016-08-04T11:48:32Z
Assigned to
nobody
Creator
turkeyman

Comments

Comment #0 by turkeyman — 2012-05-16T01:12:35Z
Currently, forward declaration is allowed, but it is presumed it is used to describe an extern function. I generate a lot of function implementations using magic, and I'd really like to describe them using the natural forward declaration rather than an ugly mixin template. Eg: // declare external interface void test(); void another(int x); // generate bindings mixin RegisterModule; // this produces code that scans the module for functions and generates their bodies This compiles, but when trying to call any such function, it produces the error: Error: function remedy.engine.debugdraw.test called with argument types: (()) matches both: remedy.engine.debugdraw.test() and: remedy.engine.debugdraw.test() One of which is the forward declaration. I think the forward declaration should silently yield the symbol to the actual function definition.
Comment #1 by github-bugzilla — 2012-11-01T13:13:51Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/1857b718be782095689fb9f015d78f54f7aa95e2 fix Issue 8108 - Forward declaration and implementation allowed in same file
Comment #2 by dfj1esp02 — 2016-08-04T11:48:32Z
*** Issue 16329 has been marked as a duplicate of this issue. ***