From d23119e24ecca16c6dc9e0107e419af89dcf2830 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Tue, 11 Oct 2016 12:38:15 +0200 Subject: [PATCH] fix(build): Make project compile using gcc5/gcc6 --- CMakeLists.txt | 2 +- include/common.hpp | 7 ++++++- include/components/bar.hpp | 10 +++++----- include/components/command_line.hpp | 6 +++--- include/components/controller.hpp | 4 ++-- include/components/logger.hpp | 4 ++++ include/components/types.hpp | 4 ++-- include/components/x11/fontmanager.hpp | 2 +- include/components/x11/randr.hpp | 14 ++++++++------ include/components/x11/tray.hpp | 6 +++--- include/utils/io.hpp | 2 +- include/utils/scope.hpp | 2 +- tests/CMakeLists.txt | 2 +- 13 files changed, 38 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75d8943b..f0e498b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ project(lemonbuddy CXX) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/modules) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-c99-extensions") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wno-unused-parameter -Wno-unused-local-typedefs") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -O0 -g2") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") diff --git a/include/common.hpp b/include/common.hpp index 145cdecd..b81c592d 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -73,7 +73,7 @@ using boost::optional; using stateflag = std::atomic; //================================================== -// Errors and exceptions +// Instance factory //================================================== namespace factory { @@ -89,6 +89,11 @@ namespace factory { } } +struct null_deleter { + template + void operator()(T*) const {} +}; + //================================================== // Errors and exceptions //================================================== diff --git a/include/components/bar.hpp b/include/components/bar.hpp index b6230c8d..8b9fdfcb 100644 --- a/include/components/bar.hpp +++ b/include/components/bar.hpp @@ -491,7 +491,7 @@ class bar : public xpp::event::sink { } else { m_log.trace("bar: Action details"); m_log.trace("action.command = %s", action.command); - m_log.trace("action.mousebtn = %i", static_cast(action.mousebtn)); + m_log.trace("action.button = %i", static_cast(action.button)); m_log.trace("action.start_x = %i", action.start_x); m_log.trace("action.end_x = %i", action.end_x); #if DEBUG and DRAW_CLICKABLE_AREA_HINTS @@ -550,7 +550,7 @@ class bar : public xpp::event::sink { if (action.active) { m_log.trace("bar: Ignoring action: unclosed)"); continue; - } else if (action.mousebtn != button) { + } else if (action.button != button) { m_log.trace("bar: Ignoring action: button mismatch"); continue; } else if (action.start_x > evt->event_x) { @@ -564,7 +564,7 @@ class bar : public xpp::event::sink { m_log.info("Found matching input area"); m_log.trace("action.command = %s", action.command); - m_log.trace("action.mousebtn = %i", static_cast(action.mousebtn)); + m_log.trace("action.button = %i", static_cast(action.button)); m_log.trace("action.start_x = %i", action.start_x); m_log.trace("action.end_x = %i", action.end_x); @@ -640,7 +640,7 @@ class bar : public xpp::event::sink { action_block action; action.active = true; action.align = m_bar.align; - action.mousebtn = btn; + action.button = btn; action.start_x = m_xpos; action.command = string_util::replace_all(cmd, ":", "\\:"); m_actions.emplace_back(action); @@ -655,7 +655,7 @@ class bar : public xpp::event::sink { for (auto i = m_actions.size(); i > 0; i--) { auto& action = m_actions[i - 1]; - if (!action.active || action.mousebtn != btn) + if (!action.active || action.button != btn) continue; action.active = false; diff --git a/include/components/command_line.hpp b/include/components/command_line.hpp index 53732765..f49ded09 100644 --- a/include/components/command_line.hpp +++ b/include/components/command_line.hpp @@ -48,8 +48,8 @@ namespace command_line { /** * Construct parser */ - explicit parser(string&& synopsis, options&& opts) - : m_synopsis(forward(synopsis)), m_opts(forward(opts)) {} + explicit parser(string&& synopsis, const options& opts) + : m_synopsis(forward(synopsis)), m_opts(opts) {} /** * Process input values @@ -134,7 +134,7 @@ namespace command_line { * Configure injection module */ template - static di::injector configure(string scriptname, options opts) { + static di::injector configure(string scriptname, const options& opts) { // clang-format off return di::make_injector( di::bind<>().to("Usage: " + scriptname + " bar_name [OPTION...]"), diff --git a/include/components/controller.hpp b/include/components/controller.hpp index bbfb5f7d..45a8923f 100644 --- a/include/components/controller.hpp +++ b/include/components/controller.hpp @@ -152,8 +152,8 @@ class controller { // Listen for events on the root window to be able to // break the blocking wait call when cleaning up m_log.trace("controller: Listen for events on the root window"); - const uint32_t value_list[]{XCB_EVENT_MASK_STRUCTURE_NOTIFY}; - m_connection.change_window_attributes(m_connection.root(), XCB_CW_EVENT_MASK, &value_list); + const uint32_t value_list[1]{XCB_EVENT_MASK_STRUCTURE_NOTIFY}; + m_connection.change_window_attributes(m_connection.root(), XCB_CW_EVENT_MASK, value_list); try { m_log.trace("controller: Setup bar renderer"); diff --git a/include/components/logger.hpp b/include/components/logger.hpp index 61e3dfd6..110566a2 100644 --- a/include/components/logger.hpp +++ b/include/components/logger.hpp @@ -145,10 +145,14 @@ class logger { auto suffix = m_suffixes.find(level)->second; // silence the compiler +#if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wformat-security" +#endif dprintf(m_fd, (prefix + format + suffix + "\n").c_str(), convert(values)...); +#if defined(__clang__) #pragma clang diagnostic pop +#endif } private: diff --git a/include/components/types.hpp b/include/components/types.hpp index 8312cd9d..589513c3 100644 --- a/include/components/types.hpp +++ b/include/components/types.hpp @@ -43,7 +43,7 @@ struct bar_settings { bool bottom{false}; bool dock{true}; - shared_ptr monitor; + monitor_t monitor; string wmname; int16_t vertical_mid{0}; @@ -90,7 +90,7 @@ struct border_settings { struct action_block { action_block() = default; - mousebtn mousebtn{mousebtn::NONE}; + mousebtn button{mousebtn::NONE}; string command; int16_t start_x{0}; int16_t end_x{0}; diff --git a/include/components/x11/fontmanager.hpp b/include/components/x11/fontmanager.hpp index 947858e7..79d67238 100644 --- a/include/components/x11/fontmanager.hpp +++ b/include/components/x11/fontmanager.hpp @@ -145,7 +145,7 @@ class fontmanager { return 0; if (font->xft == nullptr) { - if (chr - font->char_min < font->width_lut.size()) + if (static_cast(chr - font->char_min) < font->width_lut.size()) return font->width_lut[chr - font->char_min].character_width; else return font->width; diff --git a/include/components/x11/randr.hpp b/include/components/x11/randr.hpp index e752cf4b..63eb5080 100644 --- a/include/components/x11/randr.hpp +++ b/include/components/x11/randr.hpp @@ -6,7 +6,7 @@ LEMONBUDDY_NS -struct monitor { +struct randr_output { string name; int w = 0; int h = 0; @@ -14,12 +14,14 @@ struct monitor { int y = 0; }; +using monitor_t = shared_ptr; + namespace randr_util { /** * Define monitor */ - inline shared_ptr make_monitor(string name, int w, int h, int x, int y) { - auto mon = make_shared(); + inline monitor_t make_monitor(string name, int w, int h, int x, int y) { + monitor_t mon{new monitor_t::element_type{}}; mon->name = name; mon->x = x; mon->y = y; @@ -31,8 +33,8 @@ namespace randr_util { /** * Create a list of all available randr outputs */ - inline vector> get_monitors(connection& conn, xcb_window_t root) { - vector> monitors; + inline vector get_monitors(connection& conn, xcb_window_t root) { + vector monitors; auto outputs = conn.get_screen_resources(root).outputs(); for (auto it = outputs.begin(); it != outputs.end(); it++) { @@ -49,7 +51,7 @@ namespace randr_util { // use the same sort algo as lemonbar, to match the defaults sort(monitors.begin(), monitors.end(), - [](shared_ptr& m1, shared_ptr& m2) -> bool { + [](monitor_t& m1, monitor_t& m2) -> bool { if (m1->x < m2->x || m1->y + m1->h <= m2->y) return 1; if (m1->x > m2->x || m1->y + m1->h > m2->y) diff --git a/include/components/x11/tray.hpp b/include/components/x11/tray.hpp index bb355996..2e19c95e 100644 --- a/include/components/x11/tray.hpp +++ b/include/components/x11/tray.hpp @@ -2,7 +2,6 @@ #include #include -#include #include #include "common.hpp" @@ -251,7 +250,7 @@ class traymanager shared_ptr find_client(const xcb_window_t& win) { for (auto&& client : m_clients) if (client->match(win)) { - return shared_ptr{client.get(), boost::null_deleter()}; + return shared_ptr{client.get(), null_deleter{}}; } return {}; } @@ -372,7 +371,8 @@ class traymanager // } // m_logger.trace("tray: Listen for events on the new selection window"); // const uint32_t event_mask[1]{XCB_EVENT_MASK_STRUCTURE_NOTIFY}; - // m_connection.change_window_attributes_checked(m_othermanager, XCB_CW_EVENT_MASK, event_mask); + // m_connection.change_window_attributes_checked(m_othermanager, XCB_CW_EVENT_MASK, + // event_mask); // } catch (const xpp::x::error::window& err) { // m_logger.err("Failed to track selection owner"); // } diff --git a/include/utils/io.hpp b/include/utils/io.hpp index cdae6ce1..15b2685e 100644 --- a/include/utils/io.hpp +++ b/include/utils/io.hpp @@ -94,7 +94,7 @@ namespace io_util { } inline bool poll(int fd, short int events, int timeout_ms = 1) { - struct pollfd fds[0]; + struct pollfd fds[1]; fds[0].fd = fd; fds[0].events = events; diff --git a/include/utils/scope.hpp b/include/utils/scope.hpp index ac1bce78..bccb4cc6 100644 --- a/include/utils/scope.hpp +++ b/include/utils/scope.hpp @@ -33,7 +33,7 @@ namespace scope_util { * @endcode */ template , typename... Args> - decltype(auto) make_exit_handler = [](Fn&& fn, Args&&... args) -> unique_ptr> { + decltype(auto) make_exit_handler(Fn&& fn, Args&&... args) { return make_unique>(forward(fn), forward(args)...); }; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 90ab8d40..ff9e549e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) project(testsuite CXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPPUNIT_CFLAGS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Weffc++ -frtti -Wno-unused-parameter") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wno-unused-parameter -Wno-unused-local-typedefs") find_package(CppUnit REQUIRED) add_definitions(${CPPUNIT_CFLAGS_OTHER})