Compiling a template
albertas-jn
adasf at fsdk.com
Fri Dec 7 07:36:35 UTC 2018
On Friday, 7 December 2018 at 01:21:42 UTC, Ali Çehreli wrote:
> There is no trace of the template in the library or the object
> file. You can investigate the compiled symbols with e.g. the
> 'nm' tool on Linux systems:
>
> // deneme.d:
> void foo(T)(T t) {
> import std.stdio;
> writeln(t);
> }
>
> void main() {
> // foo(42);
> }
>
> $ dmd deneme.d -lib
> $ nm deneme.a | grep foo
>
> No trace of foo... Now uncomment the line in main and repeat:
>
> $ dmd deneme.d -lib
> $ nm deneme.a | grep foo
> U _D6deneme__T3fooTiZQhFNfiZv
> 0000000000000000 W _D6deneme__T3fooTiZQhFNfiZv
>
> "W" indicates a definition.
I see, what confused me was that if I put main() in a different
file and
$ dmd main.d deneme.a
the program compiled properly. Now I realize that in this case
deneme.a file was ignored and the source file was used instead. I
expected an error. Thank you for your answers.
More information about the Digitalmars-d-learn
mailing list