Why I get delegate when passing address of function?

Injeckt vinsentlou9 at gmail.com
Sun Sep 11 09:54:12 UTC 2022


On Sunday, 11 September 2022 at 09:29:23 UTC, Mike Parker wrote:
> On Sunday, 11 September 2022 at 09:15:11 UTC, Mike Parker wrote:
>
>> Pointers to non-static member functions always produce a 
>> delegate. Otherwise, you wouldn't be able to access the class 
>> instance's members.
>
> Reference:
>
> https://dlang.org/spec/function.html#closures

And what I should do to pass non-static function? I'm trying get 
function with .funcptr property, but it still doesn't work.

     CreateThread(NULL, 0, this.ClientThread.funcptr, 
cast(PVOID)clientSocket, 0, NULL);


Error: function `_server.Server.ClientThread(void* param)` is not 
callable using argument types `()`. too few arguments, expected 
`1`, got `0`


Is there ways to do that with non-static function or anyway I 
must make it static?


More information about the Digitalmars-d-learn mailing list