mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-08 01:41:59 +00:00
Show C++ version along with ODR VIOLATION DETECTED message.
This commit is contained in:
parent
a598fe6931
commit
0feb0be8c2
@ -52,6 +52,19 @@ inline std::unordered_map<std::type_index, std::string> &odr_guard_registry() {
|
|||||||
return reg;
|
return reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const char *cpp_version_in_use() {
|
||||||
|
return
|
||||||
|
#if defined(PYBIND11_CPP20)
|
||||||
|
"C++20";
|
||||||
|
#elif defined(PYBIND11_CPP17)
|
||||||
|
"C++17";
|
||||||
|
#elif defined(PYBIND11_CPP14)
|
||||||
|
"C++14";
|
||||||
|
#else
|
||||||
|
"C++11";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template <typename IntrinsicType>
|
template <typename IntrinsicType>
|
||||||
@ -72,10 +85,10 @@ bool odr_guard_impl(const std::type_index &it_ti, const char *tc_id) {
|
|||||||
auto added = ins.second;
|
auto added = ins.second;
|
||||||
if (!added && reg_iter->second != tc_id_str) {
|
if (!added && reg_iter->second != tc_id_str) {
|
||||||
std::system_error err(std::make_error_code(std::errc::state_not_recoverable),
|
std::system_error err(std::make_error_code(std::errc::state_not_recoverable),
|
||||||
"ODR VIOLATION DETECTED: pybind11::detail::type_caster<"
|
"ODR VIOLATION DETECTED (" + std::string(cpp_version_in_use())
|
||||||
+ type_id<IntrinsicType>() + ">: SourceLocation1=\""
|
+ "): pybind11::detail::type_caster<" + type_id<IntrinsicType>()
|
||||||
+ reg_iter->second + "\", SourceLocation2=\"" + tc_id_str
|
+ ">: SourceLocation1=\"" + reg_iter->second
|
||||||
+ "\"");
|
+ "\", SourceLocation2=\"" + tc_id_str + "\"");
|
||||||
#define PYBIND11_TYPE_CASTER_ODR_GUARD_THROW_OFF
|
#define PYBIND11_TYPE_CASTER_ODR_GUARD_THROW_OFF
|
||||||
#ifdef PYBIND11_TYPE_CASTER_ODR_GUARD_THROW_ON
|
#ifdef PYBIND11_TYPE_CASTER_ODR_GUARD_THROW_ON
|
||||||
throw err;
|
throw err;
|
||||||
|
Loading…
Reference in New Issue
Block a user