extern(C) and name mangling
Ali Çehreli
acehreli at yahoo.com
Wed Dec 16 04:37:54 UTC 2020
On 12/15/20 2:04 PM, Dave P. wrote:
> I want to pass
> some templated functions as function pointers to some C code
As Mike Parker said, it works:
// The same thing as a C function pointer:
alias Func = long function(int);
long bar(T)(int) {
return 0;
}
Func f0 = &(bar!float);
Func d1 = &(bar!double);
> (and that different versions would be mangled
> differently).
Yes:
auto foo(T)() {
}
void main() {
pragma(msg, foo!int.mangleof);
pragma(msg, foo!double.mangleof);
}
Output:
_D6deneme__T3fooTiZQhFNaNbNiNfZv
_D6deneme__T3fooTdZQhFNaNbNiNfZv
Ali
More information about the Digitalmars-d-learn
mailing list