Specifying C++ symbols in C++ namespaces
Tove
tove at fransson.se
Fri Apr 4 13:44:18 PDT 2014
On Friday, 4 April 2014 at 19:43:56 UTC, Walter Bright wrote:
> C++:
>
> namespace S { namespace T {
> int foo();
> namespace U {
> int foo();
> }
> } }
>
> D:
>
> extern (C++, S::T) {
> int foo();
> extern (C++, U) {
> int foo();
> }
> }
> foo(); // error, ambiguous, which one?
> S.T.foo(); // S undefined
Why would we need new ways of declaring scopes in D? Overriding
the external mangling should be sufficient? If there are
collisions you can use any type of scope you prefer to avoid the
issue, modules, structs, templates, even functions or blocks...
void fun1() { extern (C++, S::T) int foo();}
void fun2() { extern (C++, S::T::U) int foo();}
extern (C++, S::T::U) int foo();
struct test { extern (C++, S::T) int foo();}
More information about the Digitalmars-d
mailing list