D
Daniel Berger
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 <ruby.h>
#include <stdarg.h>
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 <windows.h>
#include <stdio.h>
#include <stdarg.h>
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
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 <ruby.h>
#include <stdarg.h>
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 <windows.h>
#include <stdio.h>
#include <stdarg.h>
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