diff --git a/ext/cbson/cbson.c b/ext/cbson/cbson.c index 6d0ef12..a8baf1d 100644 --- a/ext/cbson/cbson.c +++ b/ext/cbson/cbson.c @@ -112,7 +112,9 @@ static void write_utf8(buffer_t buffer, VALUE string, char check_null) { /* TODO we ought to check that the malloc or asprintf was successful * and raise an exception if not. */ -#ifdef _MSC_VER +/* TODO maybe we can use something more portable like vsnprintf instead + * of this hack. And share it with the Python extension ;) */ +#ifndef HAVE_ASPRINTF #define INT2STRING(buffer, i) \ { \ int vslength = _scprintf("%d", i) + 1; \ diff --git a/ext/cbson/extconf.rb b/ext/cbson/extconf.rb index e494ce7..ef62db7 100644 --- a/ext/cbson/extconf.rb +++ b/ext/cbson/extconf.rb @@ -1,5 +1,7 @@ require 'mkmf' +have_func("asprintf") + have_header("ruby/st.h") || have_header("st.h") have_header("ruby/regex.h") || have_header("regex.h") have_header("ruby/encoding.h")