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/go/freemail