Re: Unable to pass a D function member to a C callback

2019-11-02 Thread Dennis via Digitalmars-d-learn
On Saturday, 2 November 2019 at 20:42:29 UTC, Luh wrote: Yup that's it ! Many thanks ! One word of warning: ensure the C library does not have the only reference to your Game class instance, or the garbage collector might deallocate it since it does not scan threads created by C libraries.

Re: Unable to pass a D function member to a C callback

2019-11-02 Thread Luh via Digitalmars-d-learn
On Saturday, 2 November 2019 at 19:55:58 UTC, Dennis wrote: On Saturday, 2 November 2019 at 19:42:54 UTC, Luh wrote: So I think I just can't. :( Is that `void* c` in the callback a context pointer by any chance? That's a common thing in C callbacks precisely for purposes like this. You can

Re: Unable to pass a D function member to a C callback

2019-11-02 Thread Dennis via Digitalmars-d-learn
On Saturday, 2 November 2019 at 19:42:54 UTC, Luh wrote: So I think I just can't. :( Is that `void* c` in the callback a context pointer by any chance? That's a common thing in C callbacks precisely for purposes like this. You can cast your class to a void* when you register the callback and

Re: Unable to pass a D function member to a C callback

2019-11-02 Thread Luh via Digitalmars-d-learn
On Saturday, 2 November 2019 at 18:31:28 UTC, Stefan Koch wrote: On Saturday, 2 November 2019 at 17:49:09 UTC, Luh wrote: Hello, When trying to pass a D function to the C callback, the compiler says: 'Error: cannot implicitly convert expression of type extern (C) bool

Re: Unable to pass a D function member to a C callback

2019-11-02 Thread Alex via Digitalmars-d-learn
On Saturday, 2 November 2019 at 17:49:09 UTC, Luh wrote: Hello, When trying to pass a D function to the C callback, the compiler says: 'Error: cannot implicitly convert expression of type extern (C) bool delegate(const(short*) a, ulong b, void* c) to extern (C) bool

Re: Unable to pass a D function member to a C callback

2019-11-02 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 2 November 2019 at 17:49:09 UTC, Luh wrote: Hello, When trying to pass a D function to the C callback, the compiler says: 'Error: cannot implicitly convert expression of type extern (C) bool delegate(const(short*) a, ulong b, void* c) to extern (C) bool