New syntax for bindings to C++ and namespaces - question

Paul Backus snarwin at gmail.com
Sat Nov 3 06:02:19 UTC 2018


On Saturday, 3 November 2018 at 05:49:53 UTC, Cecil Ward wrote:
> Considering the syntax
>
>     extern( C++, "myCppNamespace" ) void cppFunc();
>
> If you want to still be able to use the namespace-qualified 
> form myCppNamespace.cppFunc() in your D, even with the string 
> type of reference, what about something like
>
>     extern( C++, "myCppNamespace" alias myCppNamespaceAlias ) 
> void cppFunc();

Use a separate module:

--- myCppNamespace.d
module myCppNamespace;

extern(C++, "myCppNamespace") void cppFunc();

--- main.d
static import myCppNamespace;

void main()
{
     myCppNamespace.cppFunc();
}


More information about the Digitalmars-d mailing list