help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] C Callouts issue


From: Stephen Woolerton
Subject: Re: [Help-smalltalk] C Callouts issue
Date: Wed, 10 Jul 2013 18:15:09 +1200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130620 Thunderbird/17.0.7

OKay, so you would like to have something like a intOut.. or does
CInt help here? Sorry, I am guessing. Or something like #selfSmallalk?

        holger
Thanks holger.

I had two issues in the last post.
One was a typo, the call to initializeNote was missing a # in the definition, i.e. #(#self)

However, I am still working on how to pass a "pointer to an unsigned int" as a C callout. The page http://www.gnu.org/software/smalltalk/manual/gst.html#C-data-types shows how to pass a pointer to a scalar when in a struct, e.g. (#example (#ptr #long)).
So I changed my script to have a similar definition:

  CNote class >> newBlankNote: retVal [
     <cCall: 'newBlankNote' returning: #{CNote} args: #((#ptr #uint)>
  ]

And here is the result when the library is called... (the first two lines come from printf statements inside the C library. The second line shows that the pointer was not actually passed into the library, it is nil)

 Inside newBlankNote: Size in bytes allocated to struct 'Note': 8
 Inside newBlankNote: resultCode pointer: [(nil)]
./ccall2.st:30: Aborted
./ccall2.st:30: Error occurred while not in byte code interpreter!!
/usr/local/lib64/libgst.so.7(+0x71ca7)[0x7f8d8d996ca7]
/lib64/libc.so.6(+0x37c50)[0x7f8d8ceb2c50]
/lib64/libc.so.6(gsignal+0x35)[0x7f8d8ceb2bd5]
/lib64/libc.so.6(abort+0x17b)[0x7f8d8ceb404b]
/usr/local/lib64/libgst.so.7(+0x2c9bb)[0x7f8d8d9519bb]
/usr/lib64/libsigsegv.so.2(+0xe7c)[0x7f8d8cc77e7c]
/lib64/libc.so.6(+0x37c50)[0x7f8d8ceb2c50]
/home/stephenw/devel_gst/ccall2/bug1/libccall2.so(newBlankNote+0x74)[0x7f8d8b7196d0]
/usr/lib64/libffi.so.6(ffi_call_unix64+0x4c)[0x7f8d8ca74ecc]
/usr/lib64/libffi.so.6(ffi_call+0x19d)[0x7f8d8ca7489d]
Aborted

Regards
Stephen





reply via email to

[Prev in Thread] Current Thread [Next in Thread]