Re: C++/TCL Need Solution to Compile Error c2784



Ok, I figure-out what I was doing wrong.

proc ::tiepie::GetSerialNumber {} {
set serial [binary format [::ffidl::info format dword] 0]
set rtn [_GetSerialNumber serial]
if {[ResultERR $rtn name info]} {
return -code error -errorinfo $info -errorcode [list TIEPIE $name $info]
}
binary scan $serial [::ffidl::info format dword] serial
return $serial
}


I wasn't setting the proper size of the byte array initially. The type is a
dword, but I had it set for word by accident. This might actually work :)

For me, ffidl is not worth the time investment, as I understand how to write
extensions in C just fine.

(bin) 32 % ::tiepie::InitInstrument
(bin) 33 % ::tiepie::GetSerialNumber
11740

^- Correct behavior!

now I unplug the unit to check for proper error return:

(bin) 34 % catch {::tiepie::GetSerialNumber}
(bin) 35 % 1
(bin) 36 % set errorInfo
Hardware is not connected
invoked from within
"::tiepie::GetSerialNumber"
(bin) 36 % set errorCode
TIEPIE E_NO_HARDWARE {Hardware is not connected}

^- Correct behavior!


So far, there are some limits I see. One particular function I want to use takes
a HANDLE type of a win32 waitable event. There is no such way to use ffidl for
such a thing as it is too low-level. I could abstract such a command, but then
I'm writing it in C anyways..

I could complete this library using ffidl, but I'd have to use the polling method
for event checking which would be lossy in terms of performance.

--
"It's great to have a friend who appreciates an earnest discussion of
ideas." -Calvin

Attachment: signature.asc
Description: OpenPGP digital signature