Skip to content

Build on windows: fixed build errors #303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5.1)
project(rpc VERSION 2.3.0)
project(xpx.rpc VERSION 2.3.0)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

Expand All @@ -8,6 +8,10 @@ include(msvc_support)
include(coverage)
include(check_warning_flag)

if(WIN32)
add_definitions(-D _WIN32_WINNT=0x0601)
endif()

#
# Options
#
Expand Down Expand Up @@ -59,6 +63,8 @@ set(CMAKE_CXX_STANDARD ${RPCLIB_CXX_STANDARD})
#
if (WIN32)
set(RPCLIB_OS_DEF "RPCLIB_WIN32")
elseif (WIN64)
set(RPCLIB_OS_DEF "RPCLIB_WIN64")
elseif (LINUX)
set(RPCLIB_OS_DEF "RPCLIB_LINUX")
elseif (APPLE)
Expand Down Expand Up @@ -90,7 +96,7 @@ set(DEP_SOURCES
${RPCLIB_DEPENDENCIES}/src/format.cc
${RPCLIB_DEPENDENCIES}/src/posix.cc)

add_library(${PROJECT_NAME}
add_library(${PROJECT_NAME} SHARED
lib/rpc/dispatcher.cc
lib/rpc/server.cc
lib/rpc/client.cc
Expand Down Expand Up @@ -261,4 +267,3 @@ if(NOT MSVC) # Don't install pkg-config files when building with MSVC
configure_file(rpclib.pc.in "${CMAKE_CURRENT_BINARY_DIR}/rpclib.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/rpclib.pc" DESTINATION "${libdir}/pkgconfig")
endif()

2 changes: 1 addition & 1 deletion doc/pages/versions.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
You are reading the documentation of 2.3.0.
You are reading the documentation of ...
If, for some reason you need the documentation of older versions, you can download them from this page.

* [1.0.0](/archive/rpclib_docs_1.0.0.zip)
9 changes: 6 additions & 3 deletions include/rpc/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ namespace rpc {
//! functions. This class supports calling functions synchronously and
//! asynchronously. When the client object is created, it initiates connecting
//! to the given server asynchronically and disconnects when it is destroyed.
#if __MINGW32__
class client {
#else
class EXPORT client {
#endif
public:
//! \brief Constructs a client.
//!
Expand Down Expand Up @@ -77,8 +81,7 @@ class client {
//! \returns A std::future, possibly holding a future result
//! (which is a RPCLIB_MSGPACK::object).
template <typename... Args>
std::future<RPCLIB_MSGPACK::object_handle> async_call(std::string const &func_name,
Args... args);
std::future<RPCLIB_MSGPACK::object_handle> async_call(std::string const &func_name, Args... args);

//! \brief Sends a notification with the given name and arguments (if any).
//!
Expand Down Expand Up @@ -144,4 +147,4 @@ class client {
};
}

#include "rpc/client.inl"
#include "rpc/client.inl"
10 changes: 10 additions & 0 deletions include/rpc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@

#include "rpc/compatibility.h"

#if defined(WIN32) || defined(WIN64)
#ifdef DLL_EXPORTS
#define EXPORT __declspec(dllexport)
#else
#define EXPORT __declspec(dllimport)
#endif
#else
#define EXPORT __attribute__ ((visibility ("default")))
#endif

namespace rpc
{

Expand Down
10 changes: 10 additions & 0 deletions include/rpc/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@

#include "rpc/compatibility.h"

#if defined(WIN32) || defined(WIN64)
#ifdef DLL_EXPORTS
#define EXPORT __declspec(dllexport)
#else
#define EXPORT __declspec(dllimport)
#endif
#else
#define EXPORT __attribute__ ((visibility ("default")))
#endif

namespace rpc
{

Expand Down
8 changes: 6 additions & 2 deletions include/rpc/dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ namespace detail {

//! \brief This class maintains a registry of functors associated with their
//! names, and callable using a msgpack-rpc call pack.
#if __MINGW32__
class dispatcher {
#else
class EXPORT dispatcher {
#endif
public:
//! \brief Binds a functor to a name so it becomes callable via RPC.
//! \param name The name of the functor.
Expand Down Expand Up @@ -96,7 +100,7 @@ class dispatcher {
//! \brief Checks the argument count and throws an exception if
//! it is not the expected amount.
static void enforce_arg_count(std::string const &func, std::size_t found,
std::size_t expected);
std::size_t expected);

void enforce_unique_name(std::string const &func);

Expand All @@ -121,4 +125,4 @@ class dispatcher {

#include "dispatcher.inl"

#endif /* end of include guard: DISPATCHER_H_CXIVZD5L */
#endif /* end of include guard: DISPATCHER_H_CXIVZD5L */
3 changes: 2 additions & 1 deletion include/rpc/msgpack/v1/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,9 @@ inline object::object(const msgpack_object& o)

inline void operator<< (clmdep_msgpack::object& o, const msgpack_object& v)
{
auto buff = static_cast<clmdep_msgpack::object>(v);
// FIXME beter way?
std::memcpy(&o, &v, sizeof(v));
std::memcpy(&o, &buff, sizeof(v));
}

inline object::operator msgpack_object() const
Expand Down
6 changes: 5 additions & 1 deletion include/rpc/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ class server_session;
//! to allow binding functions before that. Use the `run` or `async_run`
//! functions to start listening on the port.
//! This class is not copyable, but moveable.
#if __MINGW32__
class server {
#else
class EXPORT server {
#endif
public:
//! \brief Constructs a server that listens on the localhost on the
//! specified port.
Expand Down Expand Up @@ -121,4 +125,4 @@ class server {

} /* rpc */

#endif /* end of include guard: SERVER_H_S0HB5KXY */
#endif /* end of include guard: SERVER_H_S0HB5KXY */
6 changes: 3 additions & 3 deletions include/rpc/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace rpc {

static constexpr unsigned VERSION_MAJOR = 2;
static constexpr unsigned VERSION_MINOR = 3;
static constexpr unsigned VERSION_PATCH = 0;
static constexpr unsigned VERSION_MAJOR = ;
static constexpr unsigned VERSION_MINOR = ;
static constexpr unsigned VERSION_PATCH = ;

} /* rpc */

Expand Down
5 changes: 2 additions & 3 deletions lib/rpc/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ struct server::impl {
void start_accept() {
acceptor_.async_accept(socket_, [this](std::error_code ec) {
if (!ec) {
auto ep = socket_.remote_endpoint();
LOG_INFO("Accepted connection from {}:{}", ep.address(),
ep.port());
LOG_INFO("Accepted connection from {}:{}", socket_.remote_endpoint().address(),
socket_.remote_endpoint().port());
auto s = std::make_shared<server_session>(
parent_, &io_, std::move(socket_), parent_->disp_,
suppress_exceptions_);
Expand Down