Commit a6bfe2d457c6b2eb83029ec907777aa48760bd9f

Authored by Jarryd Beck
1 parent 83aecd62

Further ifdef fixes.

Related to #339.
Showing 1 changed file with 19 additions and 15 deletions
include/cxxopts.hpp
@@ -86,6 +86,17 @@ THE SOFTWARE. @@ -86,6 +86,17 @@ THE SOFTWARE.
86 #define CXXOPTS_DIAGNOSTIC_PUSH DO_PRAGMA(GCC diagnostic push) 86 #define CXXOPTS_DIAGNOSTIC_PUSH DO_PRAGMA(GCC diagnostic push)
87 #define CXXOPTS_DIAGNOSTIC_POP DO_PRAGMA(GCC diagnostic pop) 87 #define CXXOPTS_DIAGNOSTIC_POP DO_PRAGMA(GCC diagnostic pop)
88 #define CXXOPTS_IGNORE_WARNING(x) DO_PRAGMA(GCC diagnostic ignored x) 88 #define CXXOPTS_IGNORE_WARNING(x) DO_PRAGMA(GCC diagnostic ignored x)
  89 +#else
  90 +// define other compilers here if needed
  91 +#define CXXOPTS_DIAGNOSTIC_PUSH
  92 +#define CXXOPTS_DIAGNOSTIC_POP
  93 +#define CXXOPTS_IGNORE_WARNING(x)
  94 +#endif
  95 +
  96 +#ifdef CXXOPTS_NO_RTTI
  97 +#define CXXOPTS_RTTI_CAST static_cast
  98 +#else
  99 +#define CXXOPTS_RTTI_CAST dynamic_cast
89 #endif 100 #endif
90 101
91 namespace cxxopts { 102 namespace cxxopts {
@@ -169,9 +180,7 @@ class UnicodeStringIterator : public @@ -169,9 +180,7 @@ class UnicodeStringIterator : public
169 const icu::UnicodeString* s; 180 const icu::UnicodeString* s;
170 int32_t i; 181 int32_t i;
171 }; 182 };
172 -#if defined(__GNUC__)  
173 -#pragma GCC diagnostic pop  
174 -#endif 183 +CXXOPTS_DIAGNOSTIC_POP
175 184
176 inline 185 inline
177 String& 186 String&
@@ -322,13 +331,12 @@ const std::string RQUOTE("’"); @@ -322,13 +331,12 @@ const std::string RQUOTE("’");
322 #endif 331 #endif
323 } // namespace 332 } // namespace
324 333
325 -#if defined(__GNUC__)  
326 -// GNU GCC with -Weffc++ will issue a warning regarding the upcoming class, we want to silence it:  
327 -// warning: base class 'class std::enable_shared_from_this<cxxopts::Value>' has accessible non-virtual destructor  
328 -#pragma GCC diagnostic push  
329 -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"  
330 -// This will be ignored under other compilers like LLVM clang.  
331 -#endif 334 +// GNU GCC with -Weffc++ will issue a warning regarding the upcoming class, we
  335 +// want to silence it: warning: base class 'class
  336 +// std::enable_shared_from_this<cxxopts::Value>' has accessible non-virtual
  337 +// destructor This will be ignored under other compilers like LLVM clang.
  338 +CXXOPTS_DIAGNOSTIC_PUSH
  339 +CXXOPTS_IGNORE_WARNING("-Wnon-virtual-dtor")
332 class Value : public std::enable_shared_from_this<Value> 340 class Value : public std::enable_shared_from_this<Value>
333 { 341 {
334 public: 342 public:
@@ -1436,11 +1444,7 @@ CXXOPTS_DIAGNOSTIC_POP @@ -1436,11 +1444,7 @@ CXXOPTS_DIAGNOSTIC_POP
1436 m_long_names == nullptr ? "" : first_or_empty(*m_long_names)); 1444 m_long_names == nullptr ? "" : first_or_empty(*m_long_names));
1437 } 1445 }
1438 1446
1439 -#ifdef CXXOPTS_NO_RTTI  
1440 - return static_cast<const values::standard_value<T>&>(*m_value).get();  
1441 -#else  
1442 - return dynamic_cast<const values::standard_value<T>&>(*m_value).get();  
1443 -#endif 1447 + return CXXOPTS_RTTI_CAST<const values::standard_value<T>&>(*m_value).get();
1444 } 1448 }
1445 1449
1446 private: 1450 private: