From ab0b7034cf4b99fed042ae9cf42af4a307be9d18 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Thu, 7 Jan 2021 18:04:49 -0800 Subject: [PATCH] Ignore gcc-10 warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This warning trigger build errors, those pragma are a bit ugly but they prevent the build error. ``` In file included from /home/benjamin.sergeant/src/ALHttp-Cpp/build/_deps/cxxopts-src/src/example.cpp:27: /home/benjamin.sergeant/src/ALHttp-Cpp/build/_deps/cxxopts-src/include/cxxopts.hpp: In member function ‘size_t cxxopts::ParseResult::count(const string&) const’: /home/benjamin.sergeant/src/ALHttp-Cpp/build/_deps/cxxopts-src/include/cxxopts.hpp:1027:14: error: potential null pointer dereference [-Werror=null-dereference] 1027 | return m_count; | ^~~~~~~ ``` --- include/cxxopts.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp index 6ec7998..e491b2e 100644 --- a/include/cxxopts.hpp +++ b/include/cxxopts.hpp @@ -1133,12 +1133,21 @@ namespace cxxopts m_value->parse(); } +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Werror=null-dereference" +#endif + CXXOPTS_NODISCARD size_t count() const noexcept { return m_count; } + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif // TODO: maybe default options should count towards the number of arguments CXXOPTS_NODISCARD