diff options
author | Jarryd Beck <jarro.2783@gmail.com> | 2021-06-01 10:38:41 +0300 |
---|---|---|
committer | Jarryd Beck <jarro.2783@gmail.com> | 2021-06-01 10:38:41 +0300 |
commit | a20bda6179b41c0cf49d557b0b21c3fb4f6c09b7 (patch) | |
tree | e281b064e317d1d920b8c334c8fe9ae2655cf283 | |
parent | 97a4d5511ffefc81a97abd3d67b37f66e57655ee (diff) |
Fix GCC version check for null deref
Fixes #288.
-rw-r--r-- | include/cxxopts.hpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp index 1862c8b..757742a 100644 --- a/include/cxxopts.hpp +++ b/include/cxxopts.hpp @@ -70,6 +70,10 @@ THE SOFTWARE. #define CXXOPTS__VERSION_MINOR 0 #define CXXOPTS__VERSION_PATCH 0 +#if (__GNUC__ < 10 || (__GNUC__ == 10 && __GNUC_MINOR__ < 1)) && __GNUC__ >= 6 + #define CXXOPTS_NULL_DEREF_IGNORE +#endif + namespace cxxopts { static constexpr struct { @@ -1386,11 +1390,9 @@ namespace cxxopts m_long_name = &details->long_name(); } -#if defined(__GNUC__) -#if __GNUC__ <= 10 && __GNUC_MINOR__ <= 1 +#if defined(CXXOPTS_NULL_DEREF_IGNORE) #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Werror=null-dereference" -#endif +#pragma GCC diagnostic ignored "-Wnull-dereference" #endif CXXOPTS_NODISCARD @@ -1400,11 +1402,9 @@ namespace cxxopts return m_count; } -#if defined(__GNUC__) -#if __GNUC__ <= 10 && __GNUC_MINOR__ <= 1 +#if defined(CXXOPTS_NULL_DEREF_IGNORE) #pragma GCC diagnostic pop #endif -#endif // TODO: maybe default options should count towards the number of arguments CXXOPTS_NODISCARD |