C style callbacks fix for member callbacks
IntegratedDimensions
IntegratedDimensions at gmail.com
Sun May 20 16:48:00 UTC 2018
On Sunday, 20 May 2018 at 08:40:57 UTC, MGW wrote:
> On Saturday, 19 May 2018 at 23:52:58 UTC, IntegratedDimensions
> wrote:
>> I have a member callback that I want to use as a C callback.
>>
>
> http://www.agner.org/optimize/calling_conventions.pdf
>
> https://www.youtube.com/watch?v=xhDS377mAc4
Sorry, I can't understand Russian(wish I could!). It also does
not seem applicable for my problem. Although It is a useful idea
here(using D in C++).
alias callback = extern(C) int function(const(void) a, void *b,
uint c, void* context);
Where context acts as this.
I would like to assign a D method to this callback.
class
{
callback c;
/*extern(C) static*/ int foo(const(void) a, void *b, uint c,
void* context);
this() { c = cast(callback)&foo; }
}
More information about the Digitalmars-d-learn
mailing list