C function taking two function pointers that share calculation

JG someone at simewhere.com
Wed Sep 14 18:02:07 UTC 2022


On Wednesday, 14 September 2022 at 17:23:47 UTC, jmh530 wrote:
> There is a C library I sometimes use that has a function that 
> takes two function pointers. However, there are some 
> calculations that are shared between the two functions that 
> would get pointed to. I am hoping to only need to do these 
> calculations once.
>
> [...]

Maybe others know better but I would have thought the only way is 
to use globals to do this. Often c libraries that I have used get 
round this by taking a function and a pointer and then the 
library calls your function on the pointer simulating a d 
delegate.


More information about the Digitalmars-d-learn mailing list