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_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")

View File

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

View File

@ -491,7 +491,7 @@ class bar : public xpp::event::sink<evt::button_press> {
} else {
m_log.trace("bar: Action details");
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.end_x = %i", action.end_x);
#if DEBUG and DRAW_CLICKABLE_AREA_HINTS
@ -550,7 +550,7 @@ class bar : public xpp::event::sink<evt::button_press> {
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<evt::button_press> {
m_log.info("Found matching input area");
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.end_x = %i", action.end_x);
@ -640,7 +640,7 @@ class bar : public xpp::event::sink<evt::button_press> {
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<evt::button_press> {
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;

View File

@ -48,8 +48,8 @@ namespace command_line {
/**
* Construct parser
*/
explicit parser(string&& synopsis, options&& opts)
: m_synopsis(forward<string>(synopsis)), m_opts(forward<options>(opts)) {}
explicit parser(string&& synopsis, const options& opts)
: m_synopsis(forward<string>(synopsis)), m_opts(opts) {}
/**
* Process input values
@ -134,7 +134,7 @@ namespace command_line {
* Configure injection module
*/
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
return di::make_injector(
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
// 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");

View File

@ -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:

View File

@ -43,7 +43,7 @@ struct bar_settings {
bool bottom{false};
bool dock{true};
shared_ptr<monitor> 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};

View File

@ -145,7 +145,7 @@ class fontmanager {
return 0;
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;
else
return font->width;

View File

@ -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<randr_output>;
namespace randr_util {
/**
* Define monitor
*/
inline shared_ptr<monitor> make_monitor(string name, int w, int h, int x, int y) {
auto mon = make_shared<monitor>();
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<shared_ptr<monitor>> get_monitors(connection& conn, xcb_window_t root) {
vector<shared_ptr<monitor>> monitors;
inline vector<monitor_t> get_monitors(connection& conn, xcb_window_t root) {
vector<monitor_t> 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<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)
return 1;
if (m1->x > m2->x || m1->y + m1->h > m2->y)

View File

@ -2,7 +2,6 @@
#include <xcb/xcb.h>
#include <xcb/xcb_icccm.h>
#include <boost/core/null_deleter.hpp>
#include <fastdelegate/fastdelegate.hpp>
#include "common.hpp"
@ -251,7 +250,7 @@ class traymanager
shared_ptr<trayclient> find_client(const xcb_window_t& win) {
for (auto&& client : m_clients)
if (client->match(win)) {
return shared_ptr<trayclient>{client.get(), boost::null_deleter()};
return shared_ptr<trayclient>{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");
// }

View File

@ -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;

View File

@ -33,7 +33,7 @@ namespace scope_util {
* @endcode
*/
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)...);
};
}

View File

@ -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})