notify: work around GCC 4.7 compilation issue with constexpr

This can be reverted on master if we can verify that it does work with GCC 4.8.
This commit is contained in:
rdb 2019-09-16 03:27:22 +02:00
parent d7681b23d3
commit 5a23821ac1
2 changed files with 8 additions and 7 deletions

View File

@ -64,14 +64,17 @@ is_on(NotifySeverity severity) const {
return (int)severity >= (int)get_severity();
}
#if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
/**
* A shorthand way to write is_on(NS_spam).
*/
INLINE bool NotifyCategory::
is_spam() const {
#if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
// Instruct the compiler to optimize for the usual case.
return UNLIKELY(is_on(NS_spam));
#else
return false;
#endif
}
/**
@ -79,10 +82,13 @@ is_spam() const {
*/
INLINE bool NotifyCategory::
is_debug() const {
#if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
// Instruct the compiler to optimize for the usual case.
return UNLIKELY(is_on(NS_debug));
}
#else
return false;
#endif
}
/**
* A shorthand way to write is_on(NS_info).

View File

@ -51,13 +51,8 @@ PUBLISHED:
// to present a consistent interface to our scripting language, so during
// the interrogate pass (that is, when CPPPARSER is defined), we still
// pretend they're nonstatic.
#if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
INLINE bool is_spam() const;
INLINE bool is_debug() const;
#else
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;
INLINE bool is_error() const;