From d7681b23d3133109be661c9222626159aa18424b Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 15 Sep 2019 20:24:31 +0200 Subject: [PATCH] notify: fix ABI incompatibility with NDEBUG on Windows On MSVC (not with GCC/clang), adding `static` changes the mangled symbol name, so we shouldn't add that when building with NDEBUG. On GCC/clang, it doesn't, but adding `const` does, and C++11 rules make `constexpr` methods implicitly `const`, so I've removed the `constexpr` variants from NotifyCategoryProxy for now. Hopefully the compiler is still smart enough to compile out any references when compiling with NDEBUG. --- dtool/src/prc/notifyCategory.h | 4 ++-- dtool/src/prc/notifyCategoryProxy.I | 12 ++++++++---- dtool/src/prc/notifyCategoryProxy.h | 5 ----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/dtool/src/prc/notifyCategory.h b/dtool/src/prc/notifyCategory.h index 9a2a9fa4e2..db767336b1 100644 --- a/dtool/src/prc/notifyCategory.h +++ b/dtool/src/prc/notifyCategory.h @@ -55,8 +55,8 @@ PUBLISHED: INLINE bool is_spam() const; INLINE bool is_debug() const; #else - constexpr static bool is_spam() { return false; } - constexpr static bool is_debug() { return false; } + constexpr bool is_spam() const { return false; } + constexpr bool is_debug() const { return false; } #endif INLINE bool is_info() const; INLINE bool is_warning() const; diff --git a/dtool/src/prc/notifyCategoryProxy.I b/dtool/src/prc/notifyCategoryProxy.I index fbdac1f0ca..ddd10b772d 100644 --- a/dtool/src/prc/notifyCategoryProxy.I +++ b/dtool/src/prc/notifyCategoryProxy.I @@ -65,26 +65,30 @@ is_on(NotifySeverity severity) { /** * */ -#ifdef NOTIFY_DEBUG template INLINE bool NotifyCategoryProxy:: is_spam() { +#ifdef NOTIFY_DEBUG // Instruct the compiler to optimize for the usual case. return UNLIKELY(get_unsafe_ptr()->is_spam()); -} +#else + return false; #endif +} /** * */ -#ifdef NOTIFY_DEBUG template INLINE bool NotifyCategoryProxy:: is_debug() { +#ifdef NOTIFY_DEBUG // Instruct the compiler to optimize for the usual case. return UNLIKELY(get_unsafe_ptr()->is_debug()); -} +#else + return false; #endif +} /** * diff --git a/dtool/src/prc/notifyCategoryProxy.h b/dtool/src/prc/notifyCategoryProxy.h index 5465529583..5ca79a6594 100644 --- a/dtool/src/prc/notifyCategoryProxy.h +++ b/dtool/src/prc/notifyCategoryProxy.h @@ -71,13 +71,8 @@ public: INLINE bool is_on(NotifySeverity severity); -#if defined(NOTIFY_DEBUG) || defined(CPPPARSER) INLINE bool is_spam(); INLINE bool is_debug(); -#else - constexpr static bool is_spam() { return false; } - constexpr static bool is_debug() { return false; } -#endif INLINE bool is_info(); INLINE bool is_warning(); INLINE bool is_error();