www.digitalmars.com         C & C++   DMDScript  

c++ - linker error 42 when using member function pointers of template classes

reply Shinomori <aoshi gmx.net> writes:
see attached file, a more detailed description is included in the comments.

For short; the linker outputs error 42 (undefined symbol)
when using member function pointers of template classes.
Identical code works for non-templates.
begin 644 dmc_linkererror.cpp
M+RHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ
M*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ* T*1&EG:71A;"!-
M87)S($-O;7!I;&5R(%9E<G-I;VX ."XT,FX-"D-O<'ER:6=H="`H0RD 1&EG

M<FET=&5N(&)Y(%=A;'1E<B!"<FEG:'0 ('=W=RYD:6=I=&%L;6%R<RYC;VTO
M8W1G+W-C+FAT;6P-"D1-0R!I<R!A(&]N92US=&5P('!R;V=R86T =&\ 8V]M



M*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ* T*
M9&UC(&1M8U]L:6YK97)E<G)O<BYC<'`-" T*8V]M<&EL92]L:6YK+W)U;B!O

M*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ


M="!F:6YD('1H92!F=6YC=&EO;B!P;VEN=&5R<RD-" T*3U!43$E.2R`H4BD 


M<#HO+W=W=RYD:6=I=&%L;6%R<RYC;VTO8W1G+V]P=&QI;FLN:'1M;`T*9&UC





M;F-L=61E(#QS=&1L:6(N:#X-"B-I;F-L=61E(#QS


M=#Q4





M=&5S=%]S=')U8W0H*0T*"0DZ('!T<B  )G-E;&9?='EP93HZ9C$ *0T*"7M]

M8F]O;"!F,BAC;VYS="!C:&%R*BD >R!R971U<FX =')U93L ?0T*"6)O;VP 
M9C,H8V]N<W0 8VAA<BHI('L <F5T=7)N('1R=64[('T-" D-" D-" EC;VYS

M"7-T871I8R!C;VYS="!F=6YC7VUA<%]T(&%R<EM=(#T-" D)>PT*"0D)>R`F



M<FX 87)R.PT*"7T-" T*"2\O+R\O+R\O+R\O+R\O+R\O+R\O+R\O+R\O+R\O
M+R\O+R\O+R\O+R\O+R\O+R\O+R\O+R\O+R\O+R\O+R\O+R\O+R\O+R\O+R\O


M.PT*"0ES=&%T:6, 8V]N<W0 9G5N8U]M87!?="H =&%B;&5?9&%T82`]('1H
M:7,M/F=E=%]F=6YC7VUA<"AT86)L95]S:7IE*3L-" T*"0ES:7IE7W0 :3L-
M" D)9F]R*&D],#L
M9B B)3)I.B`E+3$R+C$R<R`E<UQN(BP <W1A=&EC7V-A<W0\:6YT/BAI*2P 
M=&%B;&5?9&%T85MI72YN86UE+"!T86)L95]D871A6VE=+F1E<V,I.PT*"0E]


M<W1?<W1R=6-T/&EN=#X

`
end
Jul 15 2011
parent Shinomori <aoshi gmx.net> writes:
I have done some more experiments and it
looks like a problem with the instanciation
of the member functions in templates.

When using:

func_ptr_type ptr = &function_name;

everything is fine, but with

func_ptr_type ptr[] = { &function_name };

it is not; function_name does not get instanciated
if not used otherwise.

So it is propably a compiler problem which causes
template functions not beeing instanciated when
their pointers are used inside arrays/structs only.
The functions are included when directly accessed,
however, using their pointer in e.g. an array should
also count as access, so my vague guess is an error
in the compiler.
Jul 16 2011