From: A. Vujevic on
I'm having difficulties in calling a function with ffidl.

I have a dll with a function that will compute a formula looking like this:

int __stdcall Compute (char* formula, long len, double* result);

How would I do this with ffidl (particularly how do I pass the address
of a tcl var)?

I have tried the following but I can't get a my result var set correctly:

>package require Ffidl 0.6
>set dll some.dll
>ffidl::callout compute {pointer-utf8 long pointer-var} \
> int [ffidl::symbol $dll Compute(a)12] stdcall

>set bs [binary format x[ffidl::info sizeof pointer-var]]
>set f "3.1-0.7"
>set err [Compute $f [string length $f] bs]
>binary scan $bs f res

Everything seems to work allright except for setting my result var.

Here's the output:
>puts "ErrorCode: $err \nResult: $res"
>ErrorCode: 0 <-- This means no (syntax) error in f
>Result: 4.172325418494438e-8 <-- obviously wrong

I think pointer-var might not be of the right type but I have no idea
what could be the right one.
Or am I doing the binary format and scan stuff wrong?

Any help will be appreciated.

Thanks,
Aleks