www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Template mixin / unresolved external / scope problem?

reply =?iso-8859-1?Q?Robert_M._M=FCnch?= <robert.muench saphirion.com> writes:
I have:

a.d:
extern (C) void myFuncA();

void myFuncB() {
	myFuncA();
}

b.d:
public import a;

mixin template MYFUNCA() {
	extern (C) void myFuncA() {...}
}

c.d:
import b;

mixin MYFUNCA;
...further code...


Compiling such a structure gives me an unresolved external in a.d/myFuncB

I assume this is because the mixin get's it's own scope. Is this 
correct? How can I solve such a setup?

-- 
Robert M. MŁnch
http://www.saphirion.com
smarter | better | faster
Nov 28 2019
parent reply Jacob Carlborg <doob me.com> writes:
On 2019-11-28 16:40, Robert M. M√ľnch wrote:
 I have:
 
 a.d:
 extern (C) void myFuncA();
 
 void myFuncB() {
      myFuncA();
 }
 
 b.d:
 public import a;
 
 mixin template MYFUNCA() {
      extern (C) void myFuncA() {...}
 }
 
 c.d:
 import b;
 
 mixin MYFUNCA;
 ...further code...
 
 
 Compiling such a structure gives me an unresolved external in a.d/myFuncB
 
 I assume this is because the mixin get's it's own scope. Is this 
 correct? How can I solve such a setup?
Are you using the latest version, 2.089.0? It might be fixed in that version [1]. [1] https://dlang.org/changelog/2.089.0.html#mixin_template_mangling -- /Jacob Carlborg
Nov 28 2019
parent =?iso-8859-1?Q?Robert_M._M=FCnch?= <robert.muench saphirion.com> writes:
On 2019-11-28 16:36:36 +0000, Jacob Carlborg said:

 Are you using the latest version, 2.089.0? It might be fixed in that 
 version [1].
 
 [1] https://dlang.org/changelog/2.089.0.html#mixin_template_mangling
Ha! Thanks Jacob, that looks like the root-cause. Didn't expect to use a feature which was just fixe in the newest compiler release... Using it now, but 2.089 broke some code using CAS... need to take a look into it first before I can tell if it works with the template mixin. Thanks. -- Robert M. MŁnch http://www.saphirion.com smarter | better | faster
Nov 29 2019