Forward referencing functions in D

wilcro wmcr at
Fri Oct 16 19:55:53 UTC 2020

The web page "Programming in D for C Programmers" 
( states that 
forward declarations are neither required nor permitted, and that 
the following construct is allowable:

void myfunc()

void forwardfunc()
     ... //do stuff

However, the following code will cause a compiler error:

import std.stdio: writeln;

void main()

     void myfunc() {

         forwardfunc(); // onlineapp.d(8): Error: undefined 
identifier forwardfunc

     void forwardfunc() {




Evidently, I am misunderstanding something very elemental here; 
thanks for any enlightenment regarding this.

More information about the Digitalmars-d-learn mailing list