On 06.07.2014 19:51, ParticlePeter wrote:
On Sunday, 6 July 2014 at 08:09:07 UTC, Rainer Schuetze wrote:


On 05.07.2014 16:05, ParticlePeter wrote:
...
It is possible to remove the template methods from my classes, create
free functions instead and use them in a UFCS way.
Unfortunately I have not figured out UFCS properly, as my approaches do
not work ( guess due to UFCS restrictions ).


That would not help, templates are instantiated and compiled when they
are used, not when they are declared.

Hence the idea of splitting the class. After the split, the class has
only non-template methods and is part of MyLib. Template UFCS functions
working with this class are in another module, and not part of the lib.
With this approach MyLib does not need to recompile, only the UFCS
functions module needs to recompile due to different instantiations.
UFCS works now for me btw.

Ok, that allows separate compilation of the class, but templates are still compiled with the rest of the program. I thought the templates were the part that cause the slow compilation.




I tried to not build MyLib at all, and use the sources directly, but the
project setup is kind of confusing. Again, there is a setting which I
seem to not understand fully. So one project, lets say MyProject, has
only its own module files added to the VisualD project. I want the
compiler to also use the MyLib source files, but do not want to add them
to MyProject, reasoning bellow. There is one entry in the project
properties, which should make this behavior possible, but it doses not.
Why ?

Configuration Properties - Compiler - General - Additional Imports

As far as I understand this setting, I am supposed to enter module
search paths.

This is correct.

> But I do get linker errors when I do not add either
MyLib.lib to the linker settings or all the source files of MyLib to
MyProject.


You should add a dependency in the "Project -> Project Dependencies"
dialog. This will ensure proper rebuilds and add the library to the
command line of dependent projects.

The idea is to NOT create a lib, but just use the source code from MyLib
in MyProject as additional includes. No project dependencies. I was
hoping that some .obj files are still available from last builds, and do
not need to recompile, as they are up to date ( reason for question
about not cleaning files ).

These object files are in the library ;-) That means manual selection, though, as incremental builds to multiple object files don't work with dmd, and single file compilation is painfully slow.

The modules form MyProject do import the MyLib modules properly, I do
not get compiler errors. However, the compiler should create Object
files from MyLib modules, and the linker should link them. But he does not.
On the other hand, when I add MyLib modules to MyProject ( Rightclick
MyProject - add - existing item... MyLib source files ) then linking
works. I do not understand why the later step is necessary.

dmd does not compile imported modules, but rdmd does.

Reply via email to