From fb16c8c6f61ad40d6220e74fb3152d7610cb3cef Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 25 May 2025 19:01:04 +0200 Subject: [PATCH] Trying to fix a linker issue --- src/rba/rba/rbaUtils.cc | 16 ---------------- src/rba/rba/rbaUtils.h | 12 +++++++++++- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/rba/rba/rbaUtils.cc b/src/rba/rba/rbaUtils.cc index ab4272ba1..bdb9e5c16 100644 --- a/src/rba/rba/rbaUtils.cc +++ b/src/rba/rba/rbaUtils.cc @@ -32,10 +32,6 @@ # include #endif -#if HAVE_RUBY_VERSION_CODE < 20200 -# include -#endif - static VALUE ruby_top_self = Qnil; VALUE rb_get_top_self () @@ -192,18 +188,6 @@ rba_check_error (int state) } } -#if HAVE_RUBY_VERSION_CODE < 20200 - -// Ruby <2.2 does not have this useful function -VALUE rb_utf8_str_new (const char *ptr, long len) -{ - VALUE str = rb_str_new (ptr, len); - rb_enc_associate_index (str, rb_utf8_encindex ()); - return str; -} - -#endif - /** * @brief needed because StringValue is a macro: */ diff --git a/src/rba/rba/rbaUtils.h b/src/rba/rba/rbaUtils.h index fca9b06e9..e4d4f1684 100644 --- a/src/rba/rba/rbaUtils.h +++ b/src/rba/rba/rbaUtils.h @@ -136,7 +136,17 @@ inline void rb_hash_clear(VALUE hash) #endif #if HAVE_RUBY_VERSION_CODE < 20200 -VALUE rb_utf8_str_new (const char *str, long len); + +#include + +// Ruby <2.2 does not have this useful function +inline VALUE rb_utf8_str_new (const char *ptr, long len) +{ + VALUE str = rb_str_new (ptr, len); + rb_enc_associate_index (str, rb_utf8_encindex ()); + return str; +} + #endif typedef VALUE (*ruby_func)(ANYARGS);