Ruby-dl problem: calling func with param

Discussion in 'Ruby' started by Robert Feldt, Sep 8, 2003.

  1. Robert Feldt

    Robert Feldt Guest

    Hi,

    I'm trying out ruby-dl and it looks great. However,
    I get a seg fault when calling funcs that take parameters.
    Anyone can spot the problem?

    Here's a transcript showing what I did:

    $ cat test.c
    #include <stdio.h>

    extern void hello()
    {
    printf("Hello!\n");
    }

    extern int one()
    {
    return 1;
    }

    extern int inc(int n)
    {
    return (n+1);
    }

    feldt@novomundo1 /tmp/using_ruby_dl/test
    $ gcc -shared -o test.so test.c

    feldt@novomundo1 /tmp/using_ruby_dl/test
    $ cat test.rb
    require 'dl/import'
    module Test
    extend DL::Importable
    dlload 'test.so'

    extern "void hello()"
    extern "int one()"
    extern "int inc(int)"
    end
    Test.hello
    p Test.one
    p Test.inc(2)

    feldt@novomundo1 /tmp/using_ruby_dl/test
    $ ruby test.rb
    Hello!
    1
    (eval):5: [BUG] Segmentation fault
    ruby 1.8.0 (2003-09-06) [i386-cygwin]

    Segmentation fault (core dumped)

    Regards,

    Robert Feldt
     
    Robert Feldt, Sep 8, 2003
    #1
    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. CRON
    Replies:
    24
    Views:
    203,773
    Adrienne Boswell
    Jun 20, 2006
  2. Johnny
    Replies:
    3
    Views:
    482
    Robert Kern
    Aug 23, 2005
  3. Hari Sekhon
    Replies:
    0
    Views:
    556
    Hari Sekhon
    Jun 20, 2006
  4. Alex Vinokur
    Replies:
    6
    Views:
    386
    Tor Rustad
    Nov 18, 2006
  5. Replies:
    5
    Views:
    242
    Ian Macdonald
    Dec 15, 2003
Loading...

Share This Page