fix(build): Make project compile using gcc5/gcc6

This commit is contained in:
Michael Carlberg 2016-10-11 12:38:15 +02:00
parent 3332e0f915
commit d23119e24e
13 changed files with 38 additions and 27 deletions

View File

@ -6,7 +6,7 @@ project(lemonbuddy CXX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/modules) 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_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -O0 -g2")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")

View File

@ -73,7 +73,7 @@ using boost::optional;
using stateflag = std::atomic<bool>; using stateflag = std::atomic<bool>;
//================================================== //==================================================
// Errors and exceptions // Instance factory
//================================================== //==================================================
namespace factory { namespace factory {
@ -89,6 +89,11 @@ namespace factory {
} }
} }
struct null_deleter {
template <typename T>
void operator()(T*) const {}
};
//================================================== //==================================================
// Errors and exceptions // Errors and exceptions
//================================================== //==================================================

View File

@ -491,7 +491,7 @@ class bar : public xpp::event::sink<evt::button_press> {
} else { } else {
m_log.trace("bar: Action details"); m_log.trace("bar: Action details");
m_log.trace("action.command = %s", action.command); m_log.trace("action.command = %s", action.command);
m_log.trace("action.mousebtn = %i", static_cast<int>(action.mousebtn)); m_log.trace("action.button = %i", static_cast<int>(action.button));
m_log.trace("action.start_x = %i", action.start_x); m_log.trace("action.start_x = %i", action.start_x);
m_log.trace("action.end_x = %i", action.end_x); m_log.trace("action.end_x = %i", action.end_x);
#if DEBUG and DRAW_CLICKABLE_AREA_HINTS #if DEBUG and DRAW_CLICKABLE_AREA_HINTS
@ -550,7 +550,7 @@ class bar : public xpp::event::sink<evt::button_press> {
if (action.active) { if (action.active) {
m_log.trace("bar: Ignoring action: unclosed)"); m_log.trace("bar: Ignoring action: unclosed)");
continue; continue;
} else if (action.mousebtn != button) { } else if (action.button != button) {
m_log.trace("bar: Ignoring action: button mismatch"); m_log.trace("bar: Ignoring action: button mismatch");
continue; continue;
} else if (action.start_x > evt->event_x) { } else if (action.start_x > evt->event_x) {
@ -564,7 +564,7 @@ class bar : public xpp::event::sink<evt::button_press> {
m_log.info("Found matching input area"); m_log.info("Found matching input area");
m_log.trace("action.command = %s", action.command); m_log.trace("action.command = %s", action.command);
m_log.trace("action.mousebtn = %i", static_cast<int>(action.mousebtn)); m_log.trace("action.button = %i", static_cast<int>(action.button));
m_log.trace("action.start_x = %i", action.start_x); m_log.trace("action.start_x = %i", action.start_x);
m_log.trace("action.end_x = %i", action.end_x); m_log.trace("action.end_x = %i", action.end_x);
@ -640,7 +640,7 @@ class bar : public xpp::event::sink<evt::button_press> {
action_block action; action_block action;
action.active = true; action.active = true;
action.align = m_bar.align; action.align = m_bar.align;
action.mousebtn = btn; action.button = btn;
action.start_x = m_xpos; action.start_x = m_xpos;
action.command = string_util::replace_all(cmd, ":", "\\:"); action.command = string_util::replace_all(cmd, ":", "\\:");
m_actions.emplace_back(action); m_actions.emplace_back(action);
@ -655,7 +655,7 @@ class bar : public xpp::event::sink<evt::button_press> {
for (auto i = m_actions.size(); i > 0; i--) { for (auto i = m_actions.size(); i > 0; i--) {
auto& action = m_actions[i - 1]; auto& action = m_actions[i - 1];
if (!action.active || action.mousebtn != btn) if (!action.active || action.button != btn)
continue; continue;
action.active = false; action.active = false;

View File

@ -48,8 +48,8 @@ namespace command_line {
/** /**
* Construct parser * Construct parser
*/ */
explicit parser(string&& synopsis, options&& opts) explicit parser(string&& synopsis, const options& opts)
: m_synopsis(forward<string>(synopsis)), m_opts(forward<options>(opts)) {} : m_synopsis(forward<string>(synopsis)), m_opts(opts) {}
/** /**
* Process input values * Process input values
@ -134,7 +134,7 @@ namespace command_line {
* Configure injection module * Configure injection module
*/ */
template <class T = parser> template <class T = parser>
static di::injector<T> configure(string scriptname, options opts) { static di::injector<T> configure(string scriptname, const options& opts) {
// clang-format off // clang-format off
return di::make_injector( return di::make_injector(
di::bind<>().to("Usage: " + scriptname + " bar_name [OPTION...]"), di::bind<>().to("Usage: " + scriptname + " bar_name [OPTION...]"),

View File

@ -152,8 +152,8 @@ class controller {
// Listen for events on the root window to be able to // Listen for events on the root window to be able to
// break the blocking wait call when cleaning up // break the blocking wait call when cleaning up
m_log.trace("controller: Listen for events on the root window"); m_log.trace("controller: Listen for events on the root window");
const uint32_t value_list[]{XCB_EVENT_MASK_STRUCTURE_NOTIFY}; 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); m_connection.change_window_attributes(m_connection.root(), XCB_CW_EVENT_MASK, value_list);
try { try {
m_log.trace("controller: Setup bar renderer"); m_log.trace("controller: Setup bar renderer");

View File

@ -145,10 +145,14 @@ class logger {
auto suffix = m_suffixes.find(level)->second; auto suffix = m_suffixes.find(level)->second;
// silence the compiler // silence the compiler
#if defined(__clang__)
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-security" #pragma clang diagnostic ignored "-Wformat-security"
#endif
dprintf(m_fd, (prefix + format + suffix + "\n").c_str(), convert(values)...); dprintf(m_fd, (prefix + format + suffix + "\n").c_str(), convert(values)...);
#if defined(__clang__)
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif
} }
private: private:

View File

@ -43,7 +43,7 @@ struct bar_settings {
bool bottom{false}; bool bottom{false};
bool dock{true}; bool dock{true};
shared_ptr<monitor> monitor; monitor_t monitor;
string wmname; string wmname;
int16_t vertical_mid{0}; int16_t vertical_mid{0};
@ -90,7 +90,7 @@ struct border_settings {
struct action_block { struct action_block {
action_block() = default; action_block() = default;
mousebtn mousebtn{mousebtn::NONE}; mousebtn button{mousebtn::NONE};
string command; string command;
int16_t start_x{0}; int16_t start_x{0};
int16_t end_x{0}; int16_t end_x{0};

View File

@ -145,7 +145,7 @@ class fontmanager {
return 0; return 0;
if (font->xft == nullptr) { if (font->xft == nullptr) {
if (chr - font->char_min < font->width_lut.size()) if (static_cast<size_t>(chr - font->char_min) < font->width_lut.size())
return font->width_lut[chr - font->char_min].character_width; return font->width_lut[chr - font->char_min].character_width;
else else
return font->width; return font->width;

View File

@ -6,7 +6,7 @@
LEMONBUDDY_NS LEMONBUDDY_NS
struct monitor { struct randr_output {
string name; string name;
int w = 0; int w = 0;
int h = 0; int h = 0;
@ -14,12 +14,14 @@ struct monitor {
int y = 0; int y = 0;
}; };
using monitor_t = shared_ptr<randr_output>;
namespace randr_util { namespace randr_util {
/** /**
* Define monitor * Define monitor
*/ */
inline shared_ptr<monitor> make_monitor(string name, int w, int h, int x, int y) { inline monitor_t make_monitor(string name, int w, int h, int x, int y) {
auto mon = make_shared<monitor>(); monitor_t mon{new monitor_t::element_type{}};
mon->name = name; mon->name = name;
mon->x = x; mon->x = x;
mon->y = y; mon->y = y;
@ -31,8 +33,8 @@ namespace randr_util {
/** /**
* Create a list of all available randr outputs * Create a list of all available randr outputs
*/ */
inline vector<shared_ptr<monitor>> get_monitors(connection& conn, xcb_window_t root) { inline vector<monitor_t> get_monitors(connection& conn, xcb_window_t root) {
vector<shared_ptr<monitor>> monitors; vector<monitor_t> monitors;
auto outputs = conn.get_screen_resources(root).outputs(); auto outputs = conn.get_screen_resources(root).outputs();
for (auto it = outputs.begin(); it != outputs.end(); it++) { 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 // use the same sort algo as lemonbar, to match the defaults
sort(monitors.begin(), monitors.end(), sort(monitors.begin(), monitors.end(),
[](shared_ptr<monitor>& m1, shared_ptr<monitor>& m2) -> bool { [](monitor_t& m1, monitor_t& m2) -> bool {
if (m1->x < m2->x || m1->y + m1->h <= m2->y) if (m1->x < m2->x || m1->y + m1->h <= m2->y)
return 1; return 1;
if (m1->x > m2->x || m1->y + m1->h > m2->y) if (m1->x > m2->x || m1->y + m1->h > m2->y)

View File

@ -2,7 +2,6 @@
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include <xcb/xcb_icccm.h> #include <xcb/xcb_icccm.h>
#include <boost/core/null_deleter.hpp>
#include <fastdelegate/fastdelegate.hpp> #include <fastdelegate/fastdelegate.hpp>
#include "common.hpp" #include "common.hpp"
@ -251,7 +250,7 @@ class traymanager
shared_ptr<trayclient> find_client(const xcb_window_t& win) { shared_ptr<trayclient> find_client(const xcb_window_t& win) {
for (auto&& client : m_clients) for (auto&& client : m_clients)
if (client->match(win)) { if (client->match(win)) {
return shared_ptr<trayclient>{client.get(), boost::null_deleter()}; return shared_ptr<trayclient>{client.get(), null_deleter{}};
} }
return {}; return {};
} }
@ -372,7 +371,8 @@ class traymanager
// } // }
// m_logger.trace("tray: Listen for events on the new selection window"); // m_logger.trace("tray: Listen for events on the new selection window");
// const uint32_t event_mask[1]{XCB_EVENT_MASK_STRUCTURE_NOTIFY}; // 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) { // } catch (const xpp::x::error::window& err) {
// m_logger.err("Failed to track selection owner"); // m_logger.err("Failed to track selection owner");
// } // }

View File

@ -94,7 +94,7 @@ namespace io_util {
} }
inline bool poll(int fd, short int events, int timeout_ms = 1) { 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].fd = fd;
fds[0].events = events; fds[0].events = events;

View File

@ -33,7 +33,7 @@ namespace scope_util {
* @endcode * @endcode
*/ */
template <typename Fn = function<void()>, typename... Args> template <typename Fn = function<void()>, typename... Args>
decltype(auto) make_exit_handler = [](Fn&& fn, Args&&... args) -> unique_ptr<on_exit<Args...>> { decltype(auto) make_exit_handler(Fn&& fn, Args&&... args) {
return make_unique<on_exit<Args...>>(forward<Fn>(fn), forward<Args>(args)...); return make_unique<on_exit<Args...>>(forward<Fn>(fn), forward<Args>(args)...);
}; };
} }

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(testsuite CXX) project(testsuite CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPPUNIT_CFLAGS}") 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) find_package(CppUnit REQUIRED)
add_definitions(${CPPUNIT_CFLAGS_OTHER}) add_definitions(${CPPUNIT_CFLAGS_OTHER})