I've just started to try to use SWIG to wrap a bunch of C functions so I can
call them from Ruby. If I can get this working it will make some testing
much easier, but I've come across a strange problem. Functions which take
char pointer arguments seem to pass in NULL.
#####
void sayHelloTo(char *name) {
if (NULL == name) {
printf("Hello %s\n", name);
}
else {
printf("Gimme a name!\n");
}
}
#####
ben% irb
irb(main):001:0> require 'sample'
=> true
irb(main):002:0> Sample.sayHello
Hello World
=> nil
irb(main):003:0> Sample.sayHelloTo
ArgumentError: wrong # of arguments(0 for 1)
from (irb):3:in `sayHelloTo'
from (irb):3
irb(main):004:0> Sample.sayHelloTo("Bob")
Gimme a name!
=> nil
I've looked over the documentation on the generic and Ruby-specific parts of
the SWIG site and haven't found anything talking about this issue. Any tips,
pointers, URLs or comments?