Designing an API with D.

evilrat evilrat666 at gmail.com
Mon Sep 30 20:01:26 PDT 2013


On Tuesday, 1 October 2013 at 00:37:48 UTC, Agustin wrote:
> Hello, i'm trying to make a library and i would like to use that
> library on a separated application using only interfaces. I know
> how to do it using C++, but i don't known using D. Can anyone
> help me?
>
> Project #1
> include/*.d -> These are interfaces.
> src/*.d     -> Implementation code using those interface.
>
> Project #2
> src/*.d     -> Its code using only Project #1's include folder
> without implementation code.
>
> Thanks!

first, you are in D now, forget C++ way of things please.

AFAIK people rarely use interface files this days, one reason is 
templates which needs instantiated in ur code but it won't be 
able to put them in interface files.
(though i may be wrong on it)

still if you need it, check dmd flags, there is option to 
generate interface files, after this compile ur client code with 
-I flag like this "dmd -Ipath_to_your_generated_interfaces main.d"

and at last, the simplest way is just to put whole lib sources to 
client apps, either full source added build, or build static lib 
first and -I flag in clients.


all i said above is works for open source projects, there may be 
a few problems exists with interface files at this moment, maybe 
someone related to compiler development can give you the details.

p.s. i think the most used name for D C++ include folder analog 
is import(s)


More information about the Digitalmars-d-learn mailing list