View mode: basic / threaded / horizontal-split · Log in · Help
August 08, 2003
help - class B forward reference of base class A - error
I have an
class B forward reference of base class A
error (at compilation)

obvious class B has "import A"

this is while compiling a third class C that has
import A
import B
C is on a different package.

Anybody knows what's going on?

thanks
(I had solved this yesterday by changing the imports and/or compilation order,
but because of a user error (me) I had to restore older backups
and now I'm stuck)
August 08, 2003
Re: help - class B forward reference of base class A - error
In article <bguvnu$1gse$1@digitaldaemon.com>, Ant says...
>
>class B forward reference of base class A

Here is what I found out:
if A and B refer to C
and B extends A
and C refers to B
then B must be compiled before A

WidgetBase = A
WidgetButton = B
EventDispatcher = C

------------- file WidgetBase.d
private import EventDispatcher;

class WidgetBase
{
}

------------- file WidgetButton.d
private import WidgetBase;
private import EventDispatcher;

class WidgetButton : WidgetBase
{
)

-------------- file EventDispatcher.d
private import WidgetButton;

class EventDispatcher
{
}

-------------- file Makefile
all:
dmd -v \
WidgetButton.d \
WidgetBase.d \
EventDispatcher.d \
-c \
-I~/dmd/src/phobos	


action: rm *.o ; make

### no error
### compiling WidgetButton before WidgetBase

result:

dmd -v \
WidgetButton.d \
WidgetBase.d \
EventDispatcher.d \
-c \
-I~/dmd/src/phobos      
parse     WidgetButton
parse     WidgetBase
parse     EventDispatcher
semantic  WidgetButton
semantic  WidgetBase
semantic  EventDispatcher
semantic2 WidgetButton
semantic2 WidgetBase
semantic2 EventDispatcher
semantic3 WidgetButton
semantic3 WidgetBase
semantic3 EventDispatcher
code      WidgetButton
code      WidgetBase
code      EventDispatcher


### error;
### compiling WidgetBase before WidgetButton
### means that EventDispatcher will process WidgetButton
### before WidgetButton is compiled

if I try to compile WidgetBase before WidgetButton

i.e. Makefile is:
-------------- file Makefile
all:
dmd -v \
WidgetBase.d \
WidgetButton.d \
EventDispatcher.d \
-c \
-I~/dmd/src/phobos	

action: rm *.o ; make

result:

dmd -v \
WidgetBase.d \
WidgetButton.d \
EventDispatcher.d \
-c \
-I~/dmd/src/phobos      
parse     WidgetBase
parse     WidgetButton
parse     EventDispatcher
semantic  WidgetBase
WidgetButton.d: class WidgetButton forward reference of base class WidgetBase
Top | Discussion index | About this forum | D home