Thread overview
Template mixin / unresolved external / scope problem?
Nov 28, 2019
Robert M. Münch
Nov 28, 2019
Jacob Carlborg
Nov 29, 2019
Robert M. Münch
November 28, 2019
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

November 28, 2019
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
November 29, 2019
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