Mangling template
Wusiki jeronii
wusikijeronii at gmail.com
Fri May 7 08:24:15 UTC 2021
On Friday, 7 May 2021 at 07:36:40 UTC, evilrat wrote:
> On Friday, 7 May 2021 at 06:17:32 UTC, Wusiki jeronii wrote:
>> I get the error:
>> Error: static variable `libdll` cannot be read at compile time.
>
> Check how "libdll" and "Library" is defined, this error usually
> means you are forcing it to CTFE by reading or assigning it to
> enum, class member initializer, or any other compile time stuff.
>
>> How to redefine template? Need to point all functions by type
>> manually without a template?
>
> What do you mean by redefine template?
Solved.
```d
Library libdll;
T abcd(T)(T a)
{
T function(T) fun = cast(T function(T)) libdll.loadSymbol!(
T function(T))("dll.test");
return fun(a);
}
static this()
{
libdll = Library("libs/libdll.so");
writeln(abcd!float(6.5f));
}
```
Thanks for your responses.
More information about the Digitalmars-d
mailing list