From 0b4dc1904b8dcf6cf8433bbfb2d6caba2c46dbce Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 11 Jun 2017 11:33:52 +0800 Subject: [PATCH] fix compiler errors/warnings for clang 5.0 --- include/nana/c++defines.hpp | 2 +- include/nana/gui/detail/basic_window.hpp | 2 +- include/nana/gui/widgets/listbox.hpp | 8 ++++---- include/nana/gui/widgets/menubar.hpp | 1 - source/audio/detail/buffer_preparation.cpp | 2 +- source/charset.cpp | 10 ++++++++-- source/detail/platform_spec_posix.cpp | 2 +- source/gui/animation.cpp | 2 +- source/gui/filebox.cpp | 2 +- source/gui/notifier.cpp | 3 +++ source/gui/place_parts.hpp | 4 ++-- source/gui/widgets/listbox.cpp | 4 ++-- source/gui/widgets/menubar.cpp | 2 +- source/gui/widgets/skeletons/text_editor.cpp | 2 +- source/gui/widgets/treebox.cpp | 2 +- source/paint/truetype.hpp | 2 +- 16 files changed, 29 insertions(+), 21 deletions(-) diff --git a/include/nana/c++defines.hpp b/include/nana/c++defines.hpp index 551b45bb..a9381f23 100644 --- a/include/nana/c++defines.hpp +++ b/include/nana/c++defines.hpp @@ -62,7 +62,7 @@ # else # undef STD_FILESYSTEM_NOT_SUPPORTED # endif -#elif defined(__GNUC__) +#elif defined(__GNUC__) && not defined(__clang__) # if (__GNUC__ == 4 && __GNUC_MINOR__ < 6) # define noexcept //no support of noexcept until GCC 4.6 # endif diff --git a/include/nana/gui/detail/basic_window.hpp b/include/nana/gui/detail/basic_window.hpp index 2230a422..c686f889 100644 --- a/include/nana/gui/detail/basic_window.hpp +++ b/include/nana/gui/detail/basic_window.hpp @@ -52,7 +52,7 @@ namespace detail void position(const point& pos) override; nana::point position() const override; size dimension() const override; - void dimension(const size& s); + void dimension(const size& s) override; void visible(bool visibility) override; bool visible() const override; private: diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 552b2e36..e7ac1601 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -419,7 +419,7 @@ namespace nana throw std::runtime_error("nana::listbox disallow to remove items because of immutable model"); } - void erase(std::size_t pos) override + void erase(std::size_t /*pos*/) override { throw std::runtime_error("nana::listbox disallow to remove items because of immutable model"); } @@ -434,7 +434,7 @@ namespace nana return true; } - void emplace(std::size_t pos) override + void emplace(std::size_t /*pos*/) override { throw std::runtime_error("nana::listbox disallow to remove items because of immutable model"); } @@ -444,7 +444,7 @@ namespace nana throw std::runtime_error("nana::listbox disallow to remove items because of immutable model"); } - void assign(std::size_t pos, const std::vector& cells) override + void assign(std::size_t /*pos*/, const std::vector& /*cells*/) override { throw std::runtime_error("nana::listbox disallow to remove items because of immutable model"); } @@ -454,7 +454,7 @@ namespace nana return ctrans_(container_.at(pos)); } - bool push_back(const const_virtual_pointer& dptr) override + bool push_back(const const_virtual_pointer& /*dptr*/) override { throw std::runtime_error("nana::listbox disallow to remove items because of immutable model"); } diff --git a/include/nana/gui/widgets/menubar.hpp b/include/nana/gui/widgets/menubar.hpp index b636a125..a76b21bb 100644 --- a/include/nana/gui/widgets/menubar.hpp +++ b/include/nana/gui/widgets/menubar.hpp @@ -50,7 +50,6 @@ namespace nana virtual void caption(const point&, const native_string_type&); scheme *scheme_ptr() const { return scheme_ptr_; }; private: - window handle_; graph_reference graph_; scheme *scheme_ptr_; }; diff --git a/source/audio/detail/buffer_preparation.cpp b/source/audio/detail/buffer_preparation.cpp index acd0aaa3..82942846 100644 --- a/source/audio/detail/buffer_preparation.cpp +++ b/source/audio/detail/buffer_preparation.cpp @@ -33,7 +33,7 @@ namespace nana{ namespace audio prepared_.emplace_back(m); } - thr_ = std::move(std::thread([this](){this->_m_prepare_routine();})); + thr_ = std::thread{[this](){this->_m_prepare_routine();}}; } buffer_preparation::~buffer_preparation() diff --git a/source/charset.cpp b/source/charset.cpp index 5c802b15..454b5ea3 100644 --- a/source/charset.cpp +++ b/source/charset.cpp @@ -484,7 +484,7 @@ namespace nana virtual std::string&& str_move() { if(is_unicode_) - data_ = std::move(str()); + data_ = str(); return std::move(data_); } @@ -506,6 +506,8 @@ namespace nana std::u32string u32str = std::wstring_convert, char32_t>().from_bytes(data_); return std::string(reinterpret_cast(u32str.c_str()), u32str.size() * sizeof(char32_t)); } + default: + break; //no conversion } break; case unicode::utf16: @@ -520,6 +522,8 @@ namespace nana std::u32string u32str = std::wstring_convert, char32_t>().from_bytes(data_); return std::string(reinterpret_cast(u32str.c_str()), u32str.size() * sizeof(char32_t)); } + default: + break; //no conversion } break; case unicode::utf32: @@ -533,6 +537,8 @@ namespace nana return std::wstring_convert, char32_t>().to_bytes( std::u32string(reinterpret_cast(data_.c_str()), data_.size() / sizeof(char32_t)) ); + default: + break; //no conversion } break; } @@ -588,7 +594,7 @@ namespace nana virtual std::wstring && wstr_move() { - wdata_for_move_ = std::move(wstr()); + wdata_for_move_ = wstr(); return std::move(wdata_for_move_); } private: diff --git a/source/detail/platform_spec_posix.cpp b/source/detail/platform_spec_posix.cpp index 0b7e9538..e495cf7d 100644 --- a/source/detail/platform_spec_posix.cpp +++ b/source/detail/platform_spec_posix.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include diff --git a/source/gui/animation.cpp b/source/gui/animation.cpp index a6047b4e..c737d334 100644 --- a/source/gui/animation.cpp +++ b/source/gui/animation.cpp @@ -454,7 +454,7 @@ namespace nana thr->performance_parameter = 0.0; thr->fps = p->fps; thr->interval = 1000.0 / double(p->fps); - thr->thread = std::make_shared([this, thr]() + thr->thread = std::make_shared([thr]() { nana::system::timepiece tmpiece; while (true) diff --git a/source/gui/filebox.cpp b/source/gui/filebox.cpp index ae90915d..c3fa7fb0 100644 --- a/source/gui/filebox.cpp +++ b/source/gui/filebox.cpp @@ -270,7 +270,7 @@ namespace nana return (reverse ? a > b : a < b); }); - ls_file_.set_sort_compare(3, [this](const std::string&, nana::any* anyptr_a, const std::string&, nana::any* anyptr_b, bool reverse) -> bool + ls_file_.set_sort_compare(3, [](const std::string&, nana::any* anyptr_a, const std::string&, nana::any* anyptr_b, bool reverse) -> bool { item_fs * fsa = any_cast(anyptr_a); item_fs * fsb = any_cast(anyptr_b); diff --git a/source/gui/notifier.cpp b/source/gui/notifier.cpp index 545b3a47..e3ec1b66 100644 --- a/source/gui/notifier.cpp +++ b/source/gui/notifier.cpp @@ -265,6 +265,9 @@ namespace nana auto ico = impl_->icons[impl_->play_index++]; impl_->set_icon(ico); +#else + //eliminates warnings in clang + static_cast(this); #endif }); diff --git a/source/gui/place_parts.hpp b/source/gui/place_parts.hpp index 0b4f4e23..3dde6ca9 100644 --- a/source/gui/place_parts.hpp +++ b/source/gui/place_parts.hpp @@ -68,13 +68,13 @@ namespace nana API::dev::lazy_refresh(); } - void mouse_down(graph_reference graph, const arg_mouse&) + void mouse_down(graph_reference graph, const arg_mouse&) override { refresh(graph); API::dev::lazy_refresh(); } - void mouse_up(graph_reference graph, const arg_mouse&) + void mouse_up(graph_reference graph, const arg_mouse&) override { refresh(graph); API::dev::lazy_refresh(); diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 3aa2262f..237212c4 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -195,7 +195,7 @@ namespace nana _m_refresh(); } - void width(unsigned minimum, unsigned maximum) + void width(unsigned minimum, unsigned maximum) override { //maximum must be larger than minimum, but maximum == 0 is allowed if minimum is 0 if ((minimum >= maximum) && (minimum != 0)) @@ -3531,7 +3531,7 @@ namespace nana } } private: - void _m_draw_categ(const category_t& categ, int x, int y, int txtoff, unsigned width, const nana::rectangle& r, nana::color bgcolor, item_state state) + void _m_draw_categ(const category_t& categ, int x, int y, int txtoff, unsigned width, const nana::rectangle& /*r*/, nana::color bgcolor, item_state state) { const auto item_height = essence_->item_height(); diff --git a/source/gui/widgets/menubar.cpp b/source/gui/widgets/menubar.cpp index 9b17d1e7..8ad5e35b 100644 --- a/source/gui/widgets/menubar.cpp +++ b/source/gui/widgets/menubar.cpp @@ -85,7 +85,7 @@ namespace nana //class item_renderer item_renderer::item_renderer(window wd, graph_reference graph) - :handle_(wd), graph_(graph), scheme_ptr_(static_cast(API::dev::get_scheme(wd))) + :graph_(graph), scheme_ptr_(static_cast(API::dev::get_scheme(wd))) {} void item_renderer::background(const nana::point& pos, const nana::size& size, state item_state) diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index d008d70a..11061b58 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -440,7 +440,7 @@ namespace nana{ namespace widgets ); } - bool clear() + bool clear() override { if (colored_areas_.empty()) return false; diff --git a/source/gui/widgets/treebox.cpp b/source/gui/widgets/treebox.cpp index 54c94f94..c84e66d2 100644 --- a/source/gui/widgets/treebox.cpp +++ b/source/gui/widgets/treebox.cpp @@ -2200,7 +2200,7 @@ namespace nana } path.insert(0, pnode->value.first); - return std::move(path); + return path; } return{}; } diff --git a/source/paint/truetype.hpp b/source/paint/truetype.hpp index bd44c0db..5b94cd34 100644 --- a/source/paint/truetype.hpp +++ b/source/paint/truetype.hpp @@ -66,7 +66,7 @@ namespace nana if (ifs.read(reinterpret_cast(&table_directory), sizeof table_directory).gcount() != sizeof table_directory) return; - if (reinterpret_cast("name") == reinterpret_cast(table_directory.name)) + if (*reinterpret_cast("name") == reinterpret_cast(table_directory.name)) { //const std::size_t length = _m_swap(table_directory.length); const std::size_t directory_offset = _m_swap(table_directory.offset);