Question about compile-time functions.
Johan Engelen via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Dec 14 02:55:37 PST 2016
On Wednesday, 14 December 2016 at 07:15:08 UTC, Bauss wrote:
> If a function is only called during compile-time will it be
> available at runtime?
With "available at runtime", I guess you mean "will it be part of
the object file". In that case: yes. Because even if a function
is _never_ called, it will be part of the object file (it must
be).
For templated functions, the answer is not so easy. Templates
that are only instantiated during CTFE are usually also emitted
into the object file. But, when importing a templated function
from another module, the template instantiation is not emitted to
the object file if the compiler deduces that the instantiation is
already emitted in the object file result of compiling the
imported module (to avoid unnecessary duplicate instantiations
across compilation units).
-Johan
More information about the Digitalmars-d-learn
mailing list