I have prepared a minimal reproducable example.
When I compile with 64 bit mingw and link to 64 bit versions of the dyncall libraries then the printed result is the expected 2.5000
.
Switching both to 32 bit and after a make clean
i get the printed result 0.0000
.
The problem is only with dyn-callbacks, dyncalls seem to work fine.
#include <stdio.h>
#include <assert.h>
#include <dynload/dynload.h>
#include <dyncall/dyncall.h>
#include <dyncallback/dyncall_callback.h>
char mul_cbHandler ( DCCallback *cb,
DCArgs *args, //DCArgs
DCValue *result,
void *userdata) {
double a = dcbArgDouble(args);
double b = dcbArgDouble(args);
printf("got args: %f %f\n", a, b);
result->d = a*b; // d: double
return 'f'; // i or f
}
typedef double (*fptr_d_dd)(double x, double y);
void callbReceiver(fptr_d_dd fptr) {
printf("res: %f\n", fptr(5.0f, 0.5f));
}
void testCallback() {
DCCallVM* vm = dcNewCallVM(4096);
assert(vm);
DCCallback* pcb = dcbNewCallback("dd)d", mul_cbHandler, 0);
assert(pcb);
callbReceiver((fptr_d_dd)pcb);
dcbFreeCallback(pcb);
dcFree(vm);
}
int main(void) {
testCallback();
printf("q\n");
return 0;
}