minecraft-pi-reborn/mods/src/util/cxx11_util.cpp

21 lines
597 B
C++
Raw Normal View History

2020-10-10 23:02:13 +00:00
// Use C++11 ABI
#undef _GLIBCXX_USE_CXX11_ABI
#define _GLIBCXX_USE_CXX11_ABI 1
#include <string>
2020-11-10 20:06:29 +00:00
#include <libcore/libcore.h>
2020-10-10 23:02:13 +00:00
#include "cxx11_util.h"
// Convert A C-String into A C++11 String That Can be Acessed In C++03 Code
cxx11_string create_cxx11_string(const char *str) {
std::string *new_str = new std::string(str);
int32_t new_size = sizeof (cxx11_string);
2020-11-10 20:06:29 +00:00
int32_t old_size = sizeof (*new_str);
2020-10-10 23:02:13 +00:00
if (new_size != old_size) {
2020-11-10 20:06:29 +00:00
ERR("Mismatched String Size: Expected: %i Real: %i", new_size, old_size);
2020-10-10 23:02:13 +00:00
}
return *reinterpret_cast<cxx11_string *>(new_str);
}