Wrapping multiple extern (C) declarations in a template

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Dec 14 03:10:07 PST 2014


On Saturday, 13 December 2014 at 19:03:42 UTC, aldanor wrote:
> If I now want to have exactly the same module but with all 
> function declarations wrapped as described above, I have to 
> public import it in another module and then do some template 
> magic. However, it wouldn't be possible to retain the same 
> function names since they've been imported to the namespace 
> (it's then also not possible to extern them as private 
> initially since then you won't be able to import/wrap them in a 
> different module). Hence the idea of mixing the wrapping 
> template in the initial .d header.

You can also use `static import`. That way, the imported symbols 
will only be accessible via their fully-qualified name (e.g. 
`mypackage.mybindings.foo` instead of `foo`) and won't pollute 
the module's namespace.


More information about the Digitalmars-d-learn mailing list