--nextPart2124300.OybOMo6Fzv
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Quoth Axel Etzold:
> Dear all,
>=20
> I'd like to have Ruby Inline create a Ruby method from the
> following C code:
>=20
> #include <stdio.h>
>=20
> int main(int argc, char *argv[])
> {
>     int x;
>     printf("%d\n",argc);
>     for (x=3D0; x<argc; x++)
>         printf("%s\n",argv[x]);
>     return 0;
> }
>=20
> (so that I can enter a variable number of arguments and have these
> returned.)
>=20
> Now I tried:
>=20
> #!/usr/local/bin/ruby -w
>=20
> require 'rubygems'
> require 'inline'
>=20
> class Example
>     inline(:C) do |builder|
>     builder.c 'int main(int argc,char *argv[])
> 			{
> 				int x;
> 				printf("%d\n",argc);
> 				for (x=3D0; x<argc; x++)
> 					printf("%s\n",argv[x]);
> 				return 0;
> 			}'
> 	end	=09
> end
>=20
> p Example.new.main(3,'a','b','c')
>=20
> but got:
>=20
> ERRORS! <snip>
>=20
> What am I missing ?
>=20
> Thank you very much.
>=20
> Best regards,
>=20
> Axel

This isn't how RubyInline is supposed to be used. RubyInline is mostly for=
=20
functions with a defined number of arguments AFAIK. It will infer the corre=
ct=20
ruby type <-> C type conversion automatically for you for that, but I don't=
=20
think it does varargs.

=46urthermore, if you were writing a C ruby extension with a varargs functi=
on,=20
the signature is:

  VALUE func(int argc, VALUE *argv, VALUE obj)

(Where argc is the actual number of arguments, argv is the C array of the=20
arguments, and obj is the receiver (quoting README.EXT from Ruby source).)

HTH,
=2D-=20
Konrad Meyer <konrad / tylerc.org> http://konrad.sobertillnoon.com/

--nextPart2124300.OybOMo6Fzv
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBHSOFCCHB0oCiR2cwRAudNAKDXg0jtKZOBtKC24IzKjKziUNhwkwCdHKtB
BD3ffbfti4l3iaxsisG8soI=
=SKln
-----END PGP SIGNATURE-----

--nextPart2124300.OybOMo6Fzv--