On 4/29/2014 2:01 AM, "Ola Fosheim Grøstad"
<[email protected]>" wrote:
framework1.d:
extern(C++,veclib){ struct … vec4 …; }
extern(C++,physics){ vec4 f(vec4 …) … }
framework2.d:
extern(C++,veclib){ struct … vec4 …; }
extern(C++,graphics){ void g(vec4 …) … }
application1.d:
import framework1;
import framework2;
graphics.g( physics.f(…) ); // you said this would not work?
That won't work because framework1.veclib.vec4 is not the same as
framework2.veclib.vec4, as far as D's symbol lookup is concerned.
-----
myframework.d
extern(C++,veclib){ struct … vec4 …; }
extern(C++,physics){ vec4 f(vec4 …) … }
extern(C++,graphics){ void g(vec4 …) … }
application2.d
import myframework;
graphics.g( physics.f(…) ); // but now it works?
Yes, because now there is only one myframework.veclib.vec4.
I'd do your example as:
vec.d:
extern(C++,veclib){ struct … vec4 …; }
framework1.d:
import vec;
extern(C++,physics){ vec4 f(vec4 …) … }
framework2.d:
import vec;
extern(C++,graphics){ void g(vec4 …) … }
application1.d:
import framework1;
import framework2;
graphics.g( physics.f(…) ); // works