[Issue 2168] cast extern enhancement?
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jul 3 07:16:18 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=2168
--- Comment #5 from RazvanN <razvan.nitu1305 at gmail.com> ---
(In reply to Dennis from comment #4)
> (In reply to RazvanN from comment #3)
> > And then it will work without needing the cast.
>
> That works in this reduced example, but when doing dynamic loading, you
> often load multiple functions with different signatures.
In that case, this seems to work:
```
extern(C) void* func(char*);
void main()
{
char* p = cast(char*)"func".ptr;
extern(C) int function() glFunctionFoo = cast(int function())func(p);
extern(C) int function(int) glFunctionFoo2 = cast(int
function(int))func(p);
pragma(msg, typeof(glFunctionFoo));
pragma(msg, typeof(glFunctionFoo2));
}
```
So, forcing the lhs of the assignment to extern(C) enables the cast to work.
--
More information about the Digitalmars-d-bugs
mailing list