diff --git a/ext/-test-/num2int/num2int.c b/ext/-test-/num2int/num2int.c index 5230896658..fb1ea9678d 100644 --- a/ext/-test-/num2int/num2int.c +++ b/ext/-test-/num2int/num2int.c @@ -72,13 +72,14 @@ print_num2ulong(VALUE obj, VALUE num) return Qnil; } +#ifdef HAVE_LONG_LONG static VALUE print_num2ll(VALUE obj, VALUE num) { char buf[128]; VALUE str; - sprintf(buf, "%lld", NUM2LL(num)); + sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num)); str = rb_str_new_cstr(buf); rb_io_write(rb_stdout, str); return Qnil; @@ -90,12 +91,12 @@ print_num2ull(VALUE obj, VALUE num) char buf[128]; VALUE str; - sprintf(buf, "%llu", NUM2ULL(num)); + sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num)); str = rb_str_new_cstr(buf); rb_io_write(rb_stdout, str); return Qnil; } - +#endif void Init_num2int(void) @@ -111,7 +112,9 @@ Init_num2int(void) rb_define_singleton_method(cNum2int, "print_num2long", print_num2long, 1); rb_define_singleton_method(cNum2int, "print_num2ulong", print_num2ulong, 1); +#ifdef HAVE_LONG_LONG rb_define_singleton_method(cNum2int, "print_num2ll", print_num2ll, 1); rb_define_singleton_method(cNum2int, "print_num2ull", print_num2ull, 1); +#endif } diff --git a/test/-ext-/num2int/test_num2int.rb b/test/-ext-/num2int/test_num2int.rb index 381336e0c8..b69f29a516 100644 --- a/test/-ext-/num2int/test_num2int.rb +++ b/test/-ext-/num2int/test_num2int.rb @@ -188,7 +188,7 @@ class TestNum2int < Test::Unit::TestCase assert_output((FIXNUM_MAX+1).to_s) do Num2int.print_num2ll(FIXNUM_MAX+1) end - end + end if defined?(Num2int.print_num2ll) def test_num2ull assert_output("0") do @@ -221,7 +221,7 @@ class TestNum2int < Test::Unit::TestCase assert_output((FIXNUM_MAX+1).to_s) do Num2int.print_num2ull(FIXNUM_MAX+1) end - end + end if defined?(Num2int.print_num2ull) end