www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Designing an API with D.

reply "Agustin" <agustin.l.alvarez hotmail.com> writes:
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?


include/*.d -> These are interfaces.
src/*.d     -> Implementation code using those interface.



without implementation code.

Thanks!
Sep 30 2013
parent reply "evilrat" <evilrat666 gmail.com> writes:
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?


 include/*.d -> These are interfaces.
 src/*.d     -> Implementation code using those interface.



 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)
Sep 30 2013
parent "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
On Tuesday, 1 October 2013 at 03:01:32 UTC, evilrat wrote:
 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)
The interface file needs the entire template implementation, i.e. not the interface. The -H flag generates the "header files" .di If you are wanting this to hide implementation you'll have better luck writing them by hand. No compiler is checking if .di and .d files match. D doesn't distinguish between .di or .d so you can use the -I flag on directories listing either.
Oct 01 2013