Specifying C++ symbols in C++ namespaces

Michel Fortin michel.fortin at michelf.ca
Wed Apr 2 19:14:35 PDT 2014


On 2014-04-03 01:09:43 +0000, Walter Bright <newshound2 at digitalmars.com> said:

> I considered that, but it fails because:
> 
> 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

That's a contrived example. Perhaps I'm wrong, but I'd assume the 
general use case is that all functions in a module will come from the 
same C++ namespace. For the contrived example above, I think it's fair 
you have to use a contrived solution:

	module s.t;
	extern (C++, S.T):

	int foo();

	struct U {
		static extern (C++, S.T.U):

		int foo();
	}

Alternatively you can use another module for the other namespace.


-- 
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca



More information about the Digitalmars-d mailing list