From: Daniel Berger Date: 2007-03-19T00:10:05+09:00 Subject: Problem trying to use varargs in private function within C extension Hi all, Ruby 1.8.6 Windows XP VC++ 8 This simple C extension complains of "too few arguments for call" when I try to build it. Yet, within a standalone C program it works fine. Am I forced to use varargs.h instead of stdarg.h? If so, how do I make this work? The varargs.h docs confuse me. #include #include int test(const char*, ...); /* String mandatory, encoding optional */ int test(const char* str, int encoding, ...){ int total = 0; total = encoding; printf("X: %s\n", str); printf("Encoding: %i\n", encoding); return total; } static VALUE foo_test(VALUE self){ int total = 0; total = test("hello"); /* Failure! */ printf("TOTAL: %i\n"); return self; } void Init_foo(){ VALUE cFoo = rb_define_class("Foo", rb_cObject); rb_define_method(cFoo, "test", foo_test, 0); } And here's the standalone C code that builds and runs fine: #include #include #include int test(const char*, ...); int main(){ int val = 0; val = test("hello", 3); printf("VAL: %i\n", val); return 0; } int test(const char* x, int encoding, ...){ int total = 0; total = encoding; printf("Encoding: %i\n", encoding); return total; } Thanks, Dan