Passing pointer to extern(C++) templated function
Ali Çehreli
acehreli at yahoo.com
Tue Oct 13 23:39:38 UTC 2020
On 10/13/20 4:11 PM, James Blachly wrote:
> On 10/13/20 5:23 AM, Jamie wrote:
>> Building with:
>> g++ -c a.cpp
>> dmd main.d a.o
>>
>> Throws the error:
>> /usr/bin/ld: main.o: in function `_Dmain':
>> main.d:(.text._Dmain[_Dmain]+0x31): undefined reference to `void
>> func3<int>(int*, int*)'
>> /usr/bin/ld: main.d:(.text._Dmain[_Dmain]+0x3e): undefined reference
>> to `void func4<int>(int const*, int const)'
>> collect2: error: ld returned 1 exit status
>> Error: linker exited with status 1
>>
>
> Is the template even instantiated? With just a template definition and
> an object file I am surprised you even have a symbol?
Yes, they all have explicit template instantiations on the C++ side.
I think the issue is with D's "turtles all the way down" style const. My
workaround would be to define wrapper functions that may need to do
casting on one or the other side.
Ali
More information about the Digitalmars-d-learn
mailing list