DIP61: redone to do extern(C++,N) syntax
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Tue Apr 29 12:48:37 PDT 2014
On 4/29/2014 2:01 AM, "Ola Fosheim Grøstad"
<ola.fosheim.grostad+dlang at gmail.com>" 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
More information about the Digitalmars-d
mailing list