Skip to content
Merged
8 changes: 8 additions & 0 deletions example/subscriber_generic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
*
*/

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
#include <google/protobuf/message.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#include <iostream>
#include <string>
#include <gz/transport.hh>
Expand Down
7 changes: 0 additions & 7 deletions include/gz/transport/Node.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@
#include <unordered_set>
#include <vector>

// TODO(anyone): Remove after fixing the warnings
#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <gz/msgs.hh>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#include "gz/transport/AdvertiseOptions.hh"
#include "gz/transport/config.hh"
Expand Down
3 changes: 2 additions & 1 deletion include/gz/transport/NodeShared.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#define GZ_TRANSPORT_NODESHARED_HH_

#ifdef _MSC_VER
#pragma warning(push, 0)
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
#include <google/protobuf/message.h>
#ifdef _MSC_VER
Expand Down
11 changes: 6 additions & 5 deletions include/gz/transport/RepHandler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@
#define GZ_TRANSPORT_REPHANDLER_HH_

#ifdef _MSC_VER
#pragma warning(push, 0)
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
#include <google/protobuf/message.h>
#include <google/protobuf/stubs/common.h>
#if GOOGLE_PROTOBUF_VERSION >= 3000000
#include <google/protobuf/stubs/casts.h>
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#if GOOGLE_PROTOBUF_VERSION > 2999999
#include <google/protobuf/stubs/casts.h>
#endif

#include <functional>
#include <iostream>
#include <memory>
Expand Down
3 changes: 2 additions & 1 deletion include/gz/transport/ReqHandler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#define GZ_TRANSPORT_REQHANDLER_HH_

#ifdef _MSC_VER
#pragma warning(push, 0)
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
#include <google/protobuf/message.h>
#ifdef _MSC_VER
Expand Down
11 changes: 5 additions & 6 deletions include/gz/transport/SubscriptionHandler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@
#define GZ_TRANSPORT_SUBSCRIPTIONHANDLER_HH_

#ifdef _MSC_VER
#pragma warning(push, 0)
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
#include <google/protobuf/message.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#include <google/protobuf/stubs/common.h>

#if GOOGLE_PROTOBUF_VERSION >= 3000000
#include <google/protobuf/stubs/casts.h>
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#include <chrono>
#include <iostream>
Expand Down
3 changes: 2 additions & 1 deletion include/gz/transport/TransportTypes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#define GZ_TRANSPORT_TRANSPORTTYPES_HH_

#ifdef _MSC_VER
#pragma warning(push, 0)
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
#include <google/protobuf/message.h>
#ifdef _MSC_VER
Expand Down
14 changes: 5 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
# "gtest_sources" variable.
gz_get_libsources_and_unittests(sources gtest_sources)

if (MSVC)
# Warning #4251 is the "dll-interface" warning that tells you when types used
# by a class are not being exported. These generated source files have private
# members that don't get exported, so they trigger this warning. However, the
# warning is not important since those members do not need to be interfaced
# with.
set_source_files_properties(${sources} ${gtest_sources} COMPILE_FLAGS "/wd4251 /wd4146")
endif()

# Create the library target.
gz_create_core_library(SOURCES ${sources} CXX_STANDARD 17)

Expand All @@ -24,6 +15,11 @@ target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
${ZeroMQ_TARGET}
)

target_include_directories(${PROJECT_LIBRARY_TARGET_NAME}
SYSTEM PUBLIC
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:CPPZMQ::CPPZMQ,INTERFACE_INCLUDE_DIRECTORIES>)

# Windows system library provides UUID
if (NOT MSVC)
target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
Expand Down
33 changes: 18 additions & 15 deletions src/Discovery.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,29 @@
*
*/

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <zmq.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#include <vector>

#include "gz/transport/Discovery.hh"

// Compatibility macro for ZMQ_FD_T
#if (ZMQ_VERSION >= 40303)
#define ZMQ_FD_T zmq_fd_t
#else
// Logic from newer zmq.h
#if defined _WIN32
// Windows uses a pointer-sized unsigned integer to store the socket fd.
#if defined _WIN64
#define ZMQ_FD_T unsigned __int64
#else
#define ZMQ_FD_T unsigned int
#endif
#else
#define ZMQ_FD_T int
#endif
#endif

namespace gz
{
namespace transport
Expand All @@ -36,18 +47,10 @@ inline namespace GZ_TRANSPORT_VERSION_NAMESPACE
/////////////////////////////////////////////////
bool pollSockets(const std::vector<int> &_sockets, const int _timeout)
{
#ifdef _WIN32
// Disable warning C4838
#pragma warning(push)
#pragma warning(disable: 4838)
#endif
zmq::pollitem_t items[] =
{
{0, _sockets.at(0), ZMQ_POLLIN, 0},
{0, static_cast<ZMQ_FD_T>(_sockets.at(0)), ZMQ_POLLIN, 0},
};
#ifdef _WIN32
#pragma warning(pop)
#endif

try
{
Expand Down
10 changes: 0 additions & 10 deletions src/NetUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@
# include <sys/ioctl.h>
#endif

#ifdef _MSC_VER
// Disable Windows deprecation warnings
# pragma warning(push)
#pragma warning(disable: 4996)
#endif

using namespace gz;

namespace gz
Expand Down Expand Up @@ -416,10 +410,6 @@ inline namespace GZ_TRANSPORT_VERSION_NAMESPACE
return result;
#endif
}

#ifdef _MSC_VER
#pragma warning(pop)
#endif
}
}
}
4 changes: 0 additions & 4 deletions src/Node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
#include "NodePrivate.hh"
#include "NodeSharedPrivate.hh"

#ifdef _MSC_VER
#pragma warning(disable: 4503)
#endif

using namespace gz;
using namespace transport;

Expand Down
17 changes: 0 additions & 17 deletions src/NodeShared.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@
*
*/

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <zmq.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#include <chrono>
#include <cstring>
Expand All @@ -34,14 +28,7 @@
#include <vector>
#include <unordered_map>

// TODO(anyone): Remove after fixing the warnings.
#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <gz/msgs.hh>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#include "gz/transport/AdvertiseOptions.hh"
#include "gz/transport/Discovery.hh"
Expand All @@ -55,10 +42,6 @@

#include "NodeSharedPrivate.hh"

#ifdef _MSC_VER
# pragma warning(disable: 4503)
#endif

using namespace std::chrono_literals;
using namespace gz;
using namespace transport;
Expand Down
6 changes: 0 additions & 6 deletions src/NodeSharedPrivate.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@
#ifndef GZ_TRANSPORT_NODESHAREDPRIVATE_HH_
#define GZ_TRANSPORT_NODESHAREDPRIVATE_HH_

#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <zmq.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#include <atomic>
#include <map>
Expand Down
12 changes: 5 additions & 7 deletions src/cmd/gz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,26 @@

#include <chrono>
#include <functional>
#include <google/protobuf/util/json_util.h>
#include <iostream>
#include <string>
#include <vector>

#ifdef _MSC_VER
#pragma warning(push, 0)
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
#include <gz/msgs.hh>
#include <google/protobuf/util/json_util.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#include <gz/msgs.hh>

#include "gz.hh"
#include "gz/transport/config.hh"
#include "gz/transport/Helpers.hh"
#include "gz/transport/Node.hh"

#ifdef _MSC_VER
# pragma warning(disable: 4503)
#endif

using namespace gz;
using namespace transport;

Expand Down