Missing Symbol Accessing Templated Function Through Interface
Peter via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Mar 8 03:50:32 PST 2016
Hi,
Can anyone explain to me what's causing the following code to
generate a missing symbol error...
import std.stdio;
interface IProblem {
void writeln(T...)(T arguments);
}
class Problem : IProblem {
void writeln(T...)(T arguments) {
// This is just here to have code in an implementation.
stdout.writeln("The implementation function was called.");
}
}
IProblem getProblem() {
return(new Problem());
}
void main() {
auto problem = getProblem();
problem.writeln("Some text and a number - ", 1234);
}
Now obviously this codes a bit contrived but its my attempt to
reduce an issue I'm seeing to its more concise form. Note that if
I cast the return value from the call to getProblem() to a
Problem instance this rectifies the issue but I'm unclear as to
why this might be. The error I get when I compile this is...
Undefined symbols for architecture x86_64:
"_D3app8IProblem18__T7writelnTAyaTiZ7writelnMFAyaiZv",
referenced from:
__Dmain in template_issue.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v
to see invocation)
--- errorlevel 1
dmd failed with exit code 1.
Apologies is the cause is blatantly obvious to more experienced D
coders.
Regards,
Peter
More information about the Digitalmars-d-learn
mailing list