Undefined symbol for, apparently, valid code?
rikki cattermole via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jul 5 23:48:57 PDT 2017
On 06/07/2017 7:28 AM, unleashy wrote:
> Hello. I am trying to compile this:
>
> ---
> module asd.asd;
>
> abstract class Asd
> {
> void opCall(Args...)(Args args);
> }
>
> @system unittest
> {
> class Foo : Asd
> {
> override void opCall(Args...)(Args args)
> {
> /* nothing */
> }
> }
>
> Asd a = new Foo();
>
> a(1, 2, 3);
> }
> ---
>
> This file is under source/asd/asd.d and I'm compiling with `dmd
> -unittest -main -ofasd.exe source\asd\asd.d -m32 -g` under Windows x64.
> For some reason, after the successful compilation step, the linker then
> complains:
>
> ---
> OPTLINK (R) for Win32 Release 8.00.17
> Copyright (C) Digital Mars 1989-2013 All rights reserved.
> http://www.digitalmars.com/ctg/optlink.html
> asd.obj(asd)
> Error 42: Symbol Undefined
> _D3asd3asd3Asd17__T6opCallTiTiTiZ6opCallMFiiiZv
> Error: linker exited with status 1
> ---
>
> Am I doing something wrong, or is this a linker bug?
>
> Thanks!
Templates+classes = require function body.
Why? Templated methods are not virtual, they are final and cannot be
inherited (so its a little strange that the override is valid).
More information about the Digitalmars-d-learn
mailing list