extern(C++, ns)

Manu via Digitalmars-d digitalmars-d at puremagic.com
Fri Jan 8 02:03:06 PST 2016


On 8 January 2016 at 18:11, Jacob Carlborg via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> void main()
> {
>     a();
>     b();
>     c();

Eh? This has caused me many errors in the past, perhaps in slightly
more complex situations though.
Try all this, but with structs and classes and references from member
functions to the other modules and all that good stuff.
If only one 'ns' is present (surely import can only place one ns in
the local scope?), how can it find its way through the others to find
all these symbols?

>     // ns.a(); // does not work

There are 3 different 'ns's, how could it disambiguate?

>     foo.ns.a();
>     ns.c();

I've noticed that the local ns 'wins'?

> }
>
> "ns.a()" works if there is no other extern(C++, ns), either in "main" or
> "bar". Is that working for you, or do you have more complex examples where
> the above doesn't work?

That's the problem with multiple definitions of the same ns, but I've
also had problems referring to the inner symbols without the scope
appended, which is all you really want to do (as you did at the top).

Let me do some new tests with the latest DMD, since the forward
referencing bugs were also plaguing me, I may have been hit by a lot
of false-positive failures in my tests by that bug.


More information about the Digitalmars-d mailing list