www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Instantiation of forward referenced class from template mixin

reply Jan <danijans03 student.kau.se> writes:
Why does the code below generate the linking error undefined reference to
<class>

template ok(T)
{
	class T
	{
	}
}

class test;
mixin ok!(test);

void main()
{
	test t = new test();
}
Jan 13 2008
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Jan" <danijans03 student.kau.se> wrote in message 
news:fmcsgc$ub7$1 digitalmars.com...
 Why does the code below generate the linking error undefined reference to 
 <class>

 template ok(T)
 {
 class T
 {
 }
 }

 class test;
 mixin ok!(test);

 void main()
 {
 test t = new test();
 }
To be honest I have _no_ idea what you're trying to do here. I'm actually kind of surprised that the compiler allows this code to be compiled. Are you trying to use mixins as some sort of substitute for C macros? In either case, what's with the "class test;"? You don't need function or class prototypes. Why don't you explain what you're trying to do, and we'll try to come up with a solution?
Jan 13 2008