Further ifdef fixes.

Related to #339.
This commit is contained in:
Jarryd Beck 2022-07-20 20:56:27 +10:00
parent 83aecd628e
commit a6bfe2d457

View File

@ -86,6 +86,17 @@ THE SOFTWARE.
#define CXXOPTS_DIAGNOSTIC_PUSH DO_PRAGMA(GCC diagnostic push) #define CXXOPTS_DIAGNOSTIC_PUSH DO_PRAGMA(GCC diagnostic push)
#define CXXOPTS_DIAGNOSTIC_POP DO_PRAGMA(GCC diagnostic pop) #define CXXOPTS_DIAGNOSTIC_POP DO_PRAGMA(GCC diagnostic pop)
#define CXXOPTS_IGNORE_WARNING(x) DO_PRAGMA(GCC diagnostic ignored x) #define CXXOPTS_IGNORE_WARNING(x) DO_PRAGMA(GCC diagnostic ignored x)
#else
// define other compilers here if needed
#define CXXOPTS_DIAGNOSTIC_PUSH
#define CXXOPTS_DIAGNOSTIC_POP
#define CXXOPTS_IGNORE_WARNING(x)
#endif
#ifdef CXXOPTS_NO_RTTI
#define CXXOPTS_RTTI_CAST static_cast
#else
#define CXXOPTS_RTTI_CAST dynamic_cast
#endif #endif
namespace cxxopts { namespace cxxopts {
@ -169,9 +180,7 @@ class UnicodeStringIterator : public
const icu::UnicodeString* s; const icu::UnicodeString* s;
int32_t i; int32_t i;
}; };
#if defined(__GNUC__) CXXOPTS_DIAGNOSTIC_POP
#pragma GCC diagnostic pop
#endif
inline inline
String& String&
@ -322,13 +331,12 @@ const std::string RQUOTE("");
#endif #endif
} // namespace } // namespace
#if defined(__GNUC__) // GNU GCC with -Weffc++ will issue a warning regarding the upcoming class, we
// GNU GCC with -Weffc++ will issue a warning regarding the upcoming class, we want to silence it: // want to silence it: warning: base class 'class
// warning: base class 'class std::enable_shared_from_this<cxxopts::Value>' has accessible non-virtual destructor // std::enable_shared_from_this<cxxopts::Value>' has accessible non-virtual
#pragma GCC diagnostic push // destructor This will be ignored under other compilers like LLVM clang.
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" CXXOPTS_DIAGNOSTIC_PUSH
// This will be ignored under other compilers like LLVM clang. CXXOPTS_IGNORE_WARNING("-Wnon-virtual-dtor")
#endif
class Value : public std::enable_shared_from_this<Value> class Value : public std::enable_shared_from_this<Value>
{ {
public: public:
@ -1436,11 +1444,7 @@ CXXOPTS_DIAGNOSTIC_POP
m_long_names == nullptr ? "" : first_or_empty(*m_long_names)); m_long_names == nullptr ? "" : first_or_empty(*m_long_names));
} }
#ifdef CXXOPTS_NO_RTTI return CXXOPTS_RTTI_CAST<const values::standard_value<T>&>(*m_value).get();
return static_cast<const values::standard_value<T>&>(*m_value).get();
#else
return dynamic_cast<const values::standard_value<T>&>(*m_value).get();
#endif
} }
private: private: