I'm not sure where this nntp://news.digitalmars.com/digitalmars.D.bugs:2556 links. But seems this test case gets lost? http://dstress.kuehne.cn/dstress/trunk/compile/extern_07.d module dstress.compile.extern_07; extern(C) void *wglGetProcAddress(char*); extern(C) int function() glFunctionFoo; int main(){ glFunctionFoo = cast(extern(C) int function()) wglGetProcAddress("glFunctionFoo"); return 0; }
What exactly is the bug you're reporting? - that that DStress test case seems to have been lost? If so, the product is wrongly set. - that the code behaves incorrectly? If so, please be specific.
This was an enhancement request, to allow extern(C) inside cast().
You can just declare the return type of wglGetProcAddress to be of type `int function()`: extern(C) int function() func(char*); And then it will work without needing the cast.
(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 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.
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17716 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB