[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby lnline question

Axel Etzold

11/24/2007 11:08:00 PM

Dear all,

I'd like to have Ruby Inline create a Ruby method from the
following C code:

#include <stdio.h>

int main(int argc, char *argv[])
{
int x;
printf("%d\n",argc);
for (x=0; x<argc; x++)
printf("%s\n",argv[x]);
return 0;
}

(so that I can enter a variable number of arguments and have these
returned.)

Now I tried:

#!/usr/local/bin/ruby -w

require 'rubygems'
require 'inline'

class Example
inline(:C) do |builder|
builder.c 'int main(int argc,char *argv[])
{
int x;
printf("%d\n",argc);
for (x=0; x<argc; x++)
printf("%s\n",argv[x]);
return 0;
}'
end
end

p Example.new.main(3,'a','b','c')

but got:

WARNING: 'char * argv[]' not understood
i.rb: In function â??mainâ??:
i.rb:15: error: â??argvâ?? undeclared (first use in this function)
i.rb:15: error: (Each undeclared identifier is reported only once
i.rb:15: error: for each function it appears in.)
i.rb:9: warning: return type of â??mainâ?? is not â??intâ??
/usr/local/lib/ruby/gems/1.8/gems/RubyInline-3.6.5/lib/inline.rb:402:in `build': error executing gcc -shared -fPIC -g -O2 -I /usr/local/lib/ruby/1.8/x86_64-linux -I /usr/local/include -o "/home/axel/.ruby_inline/Inline_Example_fad5.so" "/home/axel/.ruby_inline/Inline_Example_fad5.c" : 256 (CompilationError)
Renamed /home/axel/.ruby_inline/Inline_Example_fad5.c to /home/axel/.ruby_inline/Inline_Example_fad5.c.bad from /usr/local/lib/ruby/gems/1.8/gems/RubyInline-3.6.5/lib/inline.rb:679:in `inline'
from i.rb:7

What am I missing ?

Thank you very much.

Best regards,

Axel




--
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/g...