Template error on compiling ...
anonymous
anonymous at example.com
Fri Feb 28 13:16:02 PST 2014
On Friday, 28 February 2014 at 20:54:42 UTC, Robin wrote:
> Hiho,
>
> with
>
> import neoLab.core.Matrix;
>
> abstract class ElementalOperation(T = double) {
> abstract void opCall(ref Matrix!T m);
> abstract override string toString();
> }
>
> where I have made the abstract class templated "(T = double)"
> and where I have added a "!T" after "Matrix" in the opCall
> parameter list I get the following error:
>
> /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/crt1.o:
> In function `_start':
> (.text+0x20): undefined reference to `main'
> collect2: error: ld returned 1 exit status
> --- errorlevel 1
The error message is unrelated. "undefined reference to `main'"
-> no main function. You can add -main to your dmd invocation to
let the compiler generate a dummy main.
> When I leave the (T = double) template assignment out I get
> another error:
>
> neoLab/core/ElementalOperation.d(6): Error: undefined
> identifier T
Well, sure, you just removed T.
> With Tobias Pankrath's Matrix!() I get the following linker
> error:
>
> /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/crt1.o:
> In function `_start':
> (.text+0x20): undefined reference to `main'
Same as above: no main function.
> ScaleRowOperation.o: In function
>
> .... many many many lines of unuseful error messages ...
>
> (.text._D6neoLab4core6Matrix11__T6MatrixZ6Matrix6randomFxmxmdddZS6neoLab4core6Matrix11__T6MatrixZ6Matrix+0x145):
> undefined reference to
> `_D6neoLab4core9Dimension9Dimension4sizeMxFNaNbNdZm'
> collect2: error: ld returned 1 exit status
> --- errorlevel 1
Can't say much about this. Might just be fallout from previous
failures.
> So, in conclusion. I still have no clue why this more or less
> simple construct does not work but gives me errors on compiling.
Matrix!T is the way to go.
More information about the Digitalmars-d-learn
mailing list