Fix build issues

- `std::copy_n` requires to #include <algorithm>
- `std::optional` requires C++17 or newer
This commit is contained in:
German Lashevich
2022-05-29 20:10:00 +02:00
committed by fabian
parent eaa8a3ff3f
commit ae5a2c345d
2 changed files with 4 additions and 3 deletions

View File

@@ -57,7 +57,7 @@ target_link_libraries(i3ipc++
) )
target_compile_options(i3ipc++ target_compile_options(i3ipc++
PRIVATE -std=c++11 -Wall -Wextra -Wno-unused-parameter PRIVATE -std=c++17 -Wall -Wextra -Wno-unused-parameter
) )
target_compile_definitions(i3ipc++ target_compile_definitions(i3ipc++

View File

@@ -8,6 +8,7 @@ extern "C" {
#include <errno.h> #include <errno.h>
} }
#include <algorithm>
#include <cstring> #include <cstring>
#include <ios> #include <ios>
@@ -30,7 +31,7 @@ errno_error::errno_error(const std::string& msg) : ipc_error(format_errno(msg))
static const std::string g_i3_ipc_magic = "i3-ipc"; static const std::string g_i3_ipc_magic = "i3-ipc";
buf_t::buf_t(uint32_t payload_size) : buf_t::buf_t(uint32_t payload_size) :
data(sizeof(header_t) + payload_size, 0), data(sizeof(header_t) + payload_size, 0),
header(reinterpret_cast<header_t*>(data.data())), header(reinterpret_cast<header_t*>(data.data())),
payload(reinterpret_cast<char*>(data.data() + sizeof(header_t))) payload(reinterpret_cast<char*>(data.data() + sizeof(header_t)))
@@ -54,7 +55,7 @@ int32_t i3_connect(const std::string& socket_path) {
} }
(void)fcntl(sockfd, F_SETFD, FD_CLOEXEC); // What for? (void)fcntl(sockfd, F_SETFD, FD_CLOEXEC); // What for?
struct sockaddr_un addr; struct sockaddr_un addr;
memset(&addr, 0, sizeof(struct sockaddr_un)); memset(&addr, 0, sizeof(struct sockaddr_un));
addr.sun_family = AF_LOCAL; addr.sun_family = AF_LOCAL;