Replace pragmas with macros
Fixes ##339
This commit is contained in:
parent
8849551398
commit
292750d27a
@ -82,6 +82,13 @@ THE SOFTWARE.
|
|||||||
#define CXXOPTS_NULL_DEREF_IGNORE
|
#define CXXOPTS_NULL_DEREF_IGNORE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define DO_PRAGMA(x) _Pragma(#x)
|
||||||
|
#define CXXOPTS_DIAGNOSTIC_PUSH DO_PRAGMA(GCC diagnostic push)
|
||||||
|
#define CXXOPTS_DIAGNOSTIC_POP DO_PRAGMA(GCC diagnostic pop)
|
||||||
|
#define CXXOPTS_IGNORE_WARNING(x) DO_PRAGMA(GCC diagnostic ignored #x)
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace cxxopts {
|
namespace cxxopts {
|
||||||
static constexpr struct {
|
static constexpr struct {
|
||||||
uint8_t major, minor, patch;
|
uint8_t major, minor, patch;
|
||||||
@ -112,14 +119,11 @@ toLocalString(std::string s)
|
|||||||
return icu::UnicodeString::fromUTF8(std::move(s));
|
return icu::UnicodeString::fromUTF8(std::move(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
// GNU GCC with -Weffc++ will issue a warning regarding the upcoming class, we want to silence it:
|
// GNU GCC with -Weffc++ will issue a warning regarding the upcoming class, we want to silence it:
|
||||||
// warning: base class 'class std::enable_shared_from_this<cxxopts::Value>' has accessible non-virtual destructor
|
// warning: base class 'class std::enable_shared_from_this<cxxopts::Value>' has accessible non-virtual destructor
|
||||||
#pragma GCC diagnostic push
|
CXXOPTS_DIAGNOSTIC_PUSH
|
||||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
CXXOPTS_IGNORE_WARNING("-Wnon-virtual-dtor")
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
// This will be ignored under other compilers like LLVM clang.
|
// This will be ignored under other compilers like LLVM clang.
|
||||||
#endif
|
|
||||||
class UnicodeStringIterator : public
|
class UnicodeStringIterator : public
|
||||||
std::iterator<std::forward_iterator_tag, int32_t>
|
std::iterator<std::forward_iterator_tag, int32_t>
|
||||||
{
|
{
|
||||||
@ -324,7 +328,6 @@ const std::string RQUOTE("’");
|
|||||||
// warning: base class 'class std::enable_shared_from_this<cxxopts::Value>' has accessible non-virtual destructor
|
// warning: base class 'class std::enable_shared_from_this<cxxopts::Value>' has accessible non-virtual destructor
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
// This will be ignored under other compilers like LLVM clang.
|
// This will be ignored under other compilers like LLVM clang.
|
||||||
#endif
|
#endif
|
||||||
class Value : public std::enable_shared_from_this<Value>
|
class Value : public std::enable_shared_from_this<Value>
|
||||||
@ -370,9 +373,9 @@ class Value : public std::enable_shared_from_this<Value>
|
|||||||
virtual bool
|
virtual bool
|
||||||
is_boolean() const = 0;
|
is_boolean() const = 0;
|
||||||
};
|
};
|
||||||
#if defined(__GNUC__)
|
|
||||||
#pragma GCC diagnostic pop
|
CXXOPTS_DIAGNOSTIC_POP
|
||||||
#endif
|
|
||||||
namespace exceptions {
|
namespace exceptions {
|
||||||
|
|
||||||
class exception : public std::exception
|
class exception : public std::exception
|
||||||
@ -1402,8 +1405,8 @@ class OptionValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CXXOPTS_NULL_DEREF_IGNORE)
|
#if defined(CXXOPTS_NULL_DEREF_IGNORE)
|
||||||
#pragma GCC diagnostic push
|
CXXOPTS_DIAGNOSTIC_PUSH
|
||||||
#pragma GCC diagnostic ignored "-Wnull-dereference"
|
CXXOPTS_IGNORE_WARNING("-Wnull-dereference")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CXXOPTS_NODISCARD
|
CXXOPTS_NODISCARD
|
||||||
@ -1414,7 +1417,7 @@ class OptionValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CXXOPTS_NULL_DEREF_IGNORE)
|
#if defined(CXXOPTS_NULL_DEREF_IGNORE)
|
||||||
#pragma GCC diagnostic pop
|
CXXOPTS_DIAGNOSTIC_POP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO: maybe default options should count towards the number of arguments
|
// TODO: maybe default options should count towards the number of arguments
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user