ffidl: call dll function wiith var by ref

  • Follow


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@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
0
Reply a.vujevic (1) 3/5/2010 9:05:15 PM


0 Replies
404 Views

(page loaded in 0.041 seconds)

Similiar Articles:






7/24/2012 3:14:17 AM


Reply: