extern(C++, NS)

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Nov 29 10:48:50 PST 2015


On 11/28/2015 9:17 PM, Manu via Digitalmars-d wrote:
> On 29 November 2015 at 14:57, Walter Bright via Digitalmars-d
> <digitalmars-d at puremagic.com> wrote:
>>
>> D does not support C++ semantics. You cannot split namespaces into multiple
>> files in D, nor can you add symbols to an existing namespace. For namespace
>> NS, all the declarations in NS have to be in one file and between the { },
>> just like any other scope in D.
>
> Then the feature fails. You can't put the entire STL in one file.
> C++ doesn't namespace per file, it generally namespaces per project...
> so this is the common case; every module define symbols in the same
> C++ namespace.

You can also do this:

extern (C++, NS)
{
     mixin(import("file1.d"));
     mixin(import("file2.d"));
}



> Maybe a special case for C++ namespaces?

Please, no. Unending confusion and bugs will result.


> C++ tends to namespace everything with the same namespace, and that
> means either I implement the entire C++ library in a single module

You only need the declarations, not the implementations.



More information about the Digitalmars-d mailing list