Search code examples
templatesshared-librariesd

Templates and Shared Libraries in D


I just realized something:

Nearly everything in D is becoming templated. That' awesome for a single executable, but how does that work with shared libraries? If no code is generated until it's compiled, then D can't make shared libraries that use templates, can it? (e.g. Phobos has to be static -- there's no other way, right?)


Solution

  • Well, it's the same issue like with C++ code.

    Only the non-templated parts can be precompiled. Everything else must be provided with full source code.

    Phobos being a shared or static library doesn't make much difference here. It's still static because of dmd's issues with shared libraries.