from "int cfunc(char *data,int *num) " how can I get the value of'num' in ruby/dl ?

Discussion in 'Ruby' started by bbmerong, Jan 18, 2008.

  1. bbmerong

    bbmerong Guest

    I have a question about "ruby/dl".

    I define the function in "ruby/dl" like the belows


    --------------------------------------
    require 'dl'
    LIB=DL.dlopen('libfunc.dll')
    cfunc=LIB['cfunc','ISi'] # int cfunc(char *data,int *num)
    ---------------------------------------


    After typing in irb, I typed them like this.


    len=DL.malloc(DL.sizeof("I"))
    err=cfunc.call("hello",len)


    But, error message is displayed like the belows.


    "TypeError: can't convert DL::ptrData into Integer"


    I'm not sure how to solve the problem.

    It makes me annoying


    Please let me know the reason and solutions for novice like me.


    Then, Thank you in advance.
    bbmerong, Jan 18, 2008
    #1
    1. Advertising

  2. Re: from "int cfunc(char *data,int *num) " how can I get the value of 'num' in ruby/dl ?

    [Note: parts of this message were removed to make it a legal post.]

    Stop posting the same thing. If you don't get an answer, maybe you need to
    restate your question.

    Jason

    On Jan 17, 2008 10:19 PM, bbmerong <> wrote:

    > I have a question about "ruby/dl".
    >
    > I define the function in "ruby/dl" like the belows
    >
    >
    > --------------------------------------
    > require 'dl'
    > LIB=DL.dlopen('libfunc.dll')
    > cfunc=LIB['cfunc','ISi'] # int cfunc(char *data,int *num)
    > ---------------------------------------
    >
    >
    > After typing in irb, I typed them like this.
    >
    >
    > len=DL.malloc(DL.sizeof("I"))
    > err=cfunc.call("hello",len)
    >
    >
    > But, error message is displayed like the belows.
    >
    >
    > "TypeError: can't convert DL::ptrData into Integer"
    >
    >
    > I'm not sure how to solve the problem.
    >
    > It makes me annoying
    >
    >
    > Please let me know the reason and solutions for novice like me.
    >
    >
    > Then, Thank you in advance.
    >
    >
    >
    >
    Jason Roelofs, Jan 18, 2008
    #2
    1. Advertising

  3. bbmerong

    Ken Bloom Guest

    Re: from "int cfunc(char *data,int *num) " how can I get the valueof 'num' in ruby/dl ?

    On Thu, 17 Jan 2008 22:23:52 -0500, Jason Roelofs wrote:
    > Stop posting the same thing. If you don't get an answer, maybe you need
    > to restate your question.


    Calm down. The same message, posted two minutes apart, probably means a
    mail server hiccuped somewhere along the line, and probably doesn't mean
    the poster had any intention to be rude or pushy.

    --Ken
    (Who finally got his mail unstuck yesterday after nobody recieved the
    emails he sent for over a week.)

    --
    Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory.
    Department of Computer Science. Illinois Institute of Technology.
    http://www.iit.edu/~kbloom1/
    Ken Bloom, Jan 18, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Francis Bell

    get(char*, num, delim) question

    Francis Bell, May 22, 2004, in forum: C++
    Replies:
    12
    Views:
    1,307
    Francis Bell
    May 24, 2004
  2. Alex Vinokur
    Replies:
    1
    Views:
    3,981
    Alex Vinokur
    Feb 12, 2005
  3. bbmerong
    Replies:
    0
    Views:
    113
    bbmerong
    Jan 17, 2008
  4. bbmerong
    Replies:
    0
    Views:
    140
    bbmerong
    Jan 18, 2008
  5. lian ravago

    How to get the num of days absent using c#

    lian ravago, Dec 1, 2003, in forum: Javascript
    Replies:
    2
    Views:
    87
    GIMME
    Dec 1, 2003
Loading...

Share This Page