I'm getting an unhelpful linker error, what've I got wrong?

pineapple via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 28 04:11:00 PDT 2015


When I attempt to compile my code I get the same linker error 
with both dmd and ldc2. I know where the problematic code is, as 
I don't get the error when I comment out lines 102 through 107, 
but I don't understand why it's bad. I must have some 
misconceptions about how templates work? Is there any way to get 
more descriptive errors out of the compiler if this sort of thing 
happens again in the future?

Here's the code:

     http://pastebin.com/kGUPVa59

Here's the problematic lines:

     final streamint writestring(in char[] str){
         return this.writebuffer!char(str.ptr, str.length);
     }
     final streamint writestring(in string str){
         return this.writebuffer!char(str.ptr, str.length);
     }

And the linker error:

     Undefined symbols for architecture x86_64:
       
"_D6stream6Stream19__T11writebufferTaZ11writebufferMFxPaxlZl", 
referenced from:
           _D6stream6Stream11writestringMFxAaZl in stream.o
           _D6stream6Stream11writestringMFxAyaZl in stream.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


More information about the Digitalmars-d-learn mailing list