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



On Apr 14, 4:24 pm, David Gravereaux <davyg...@xxxxxxxxx> wrote:
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

signature.asc
1KDownload

Well, I guess my post from Friday Night (or was it Saturday Morning)
didn't go through. Well David, you may win the bet. I found my old
Brent Welch's book and looked at his example and yours to get an idea
how the TCL C API works. I think I have a handle of it. Got concern
when I could find a Tcl_Get???FromObj for unsigned short, unitl I
noticed you provided a link for the TCL Library. After sum reading, I
noticed that Tcl_GetIntFromObj should do it. So far I'm only
attempting to "hand glue" the code for 'Connect' and 'Disconnect'
prototypes. If I can get this to work, (To Compile, to Load and talk
to the device without any crashes) would be a major relief. I'm still
getting some errors but I'm trying to resolve them (forcing me to re-
learn C again). But if I can't get it to work, I plan to post it
somewhere and see if someone can tell me what the hell I'm doing. I
been so spoiled by TCL, BASH, and C-SHELL, that I totally forgot the
concept of character arrays.

Question: Brent's book mentions to build two prototypes and
definitions:
Tcl_CreateCommand
Tcl_CreateObjCommand
Should I bother to create both?

Question: The second arguement (parameter) for the function
Tcl_CreateObjCommand; is this the name of the command that I will use
via TCL, to call the C Function?

Question: I'm getting a few of these warnings: "jnior310tcl.c(215) :
warning C4020: 'Tcl_GetStringFromObj' : too many actual parameters"
The examples I found, use three parameters but the "tcl.h" defines the
protoype with only two parameters. Should I been concern? And What
the Hell! passing two arguements when it expects two! This warning
message also applies to other Tcl_GetXXXXX calls.

Question (last one): Posting the project for someone to take a crack
at the 'Connect' and 'Disconnect' prototypes to much?

BTW: David, The two prototypes "hand glue" are about 275 lines
(included blank lines and comments), I got 56 more to go (once I get
things working), but man!!! You had to do 88, that is a lot. Still
wishing CPPTCL would had work for me, but the MS VC++ compiler just
couldn't handle BOOST.

.



Relevant Pages

  • Re: function and structures
    ... C code and i have to rewrite the code in TcL. ... is to assign to it with a set command (or some other commands such ... probably the best way is to use a Tcl array. ... Functions are declared with the proc command: ...
    (comp.lang.tcl)
  • Re: function and structures
    ... lines,, i want to implement the same in TcL. ... is to assign to it with a set command (or some other commands such ... probably the best way is to use a Tcl array. ... Functions are declared with the proc command: ...
    (comp.lang.tcl)
  • Re: Question concerning object-oriented programming
    ... Dispose has to do with releasing unmanaged resources (though there are ... printable and readable string in all human languages. ... What the [array get] does is create a list, and then the list has its ... I also wrote my own data structure code in C as a loadable Tcl ...
    (comp.programming)
  • Re: 2D arrays simulated using lists
    ... I would be very sad to see you believe Tcl doesn't meet your ... of index, so I'm comparing the indexes at first, then I'm comparing ... using [array set] because I thought that it would make the whole ... array set ListeActuelleAgents [list ...
    (comp.lang.tcl)
  • Re: Help! mem leak in c extension.
    ... But I guess the non specificity of the progs and specially the ... through simple disciplines of measurement and ... array as a tcl array or as a list. ...
    (comp.lang.tcl)