diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bb7da040a..ac08140764 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8) project(ntcore) if (MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -pedantic -Wno-unused-parameter") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DNOMINMAX /D_SCL_SECURE_NO_WARNINGS") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wformat=2 -Wall -Wextra -Werror -pedantic -Wno-unused-parameter") endif() diff --git a/include/llvm/StringExtras.h b/include/llvm/StringExtras.h index 1ddb9ca351..d5a8debe19 100644 --- a/include/llvm/StringExtras.h +++ b/include/llvm/StringExtras.h @@ -15,6 +15,7 @@ #define LLVM_ADT_STRINGEXTRAS_H #include "llvm/StringRef.h" +#include #include namespace llvm { diff --git a/include/networktables/NetworkTable.h b/include/networktables/NetworkTable.h index c66e10d11c..beccab3251 100644 --- a/include/networktables/NetworkTable.h +++ b/include/networktables/NetworkTable.h @@ -10,7 +10,8 @@ class NetworkTable : public ITable { struct private_init {}; std::string m_path; - std::vector> m_listeners; + typedef std::pair Listener; + std::vector m_listeners; static std::string s_ip_address; static bool s_client; diff --git a/include/nt_Value.h b/include/nt_Value.h index d99f8ea89b..308e436536 100644 --- a/include/nt_Value.h +++ b/include/nt_Value.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "llvm/ArrayRef.h" @@ -103,7 +104,7 @@ class Value { val->m_val.data.v_string.len = val->m_string.size(); return val; } - template + template >> static std::shared_ptr MakeString(T&& value) { auto val = std::make_shared(NT_STRING, private_init()); val->m_string = std::move(value); @@ -118,7 +119,7 @@ class Value { val->m_val.data.v_raw.len = val->m_string.size(); return val; } - template + template >> static std::shared_ptr MakeRaw(T&& value) { auto val = std::make_shared(NT_RAW, private_init()); val->m_string = std::move(value); diff --git a/src/Dispatcher.h b/src/Dispatcher.h index 865d9667cb..e00a9c90b0 100644 --- a/src/Dispatcher.h +++ b/src/Dispatcher.h @@ -85,6 +85,13 @@ class DispatcherBase { Connection() = default; explicit Connection(std::unique_ptr net_) : net(std::move(net_)) {} + Connection(Connection&& rhs) { + net = std::move(rhs.net); + outgoing = std::move(rhs.outgoing); + last_update = std::move(rhs.last_update); + } + Connection(const Connection&) = delete; + Connection& operator=(const Connection&) = delete; void QueueOutgoing(std::shared_ptr msg); std::unique_ptr net; diff --git a/src/Log.h b/src/Log.h index ab47f6f721..d42b6f5e8f 100644 --- a/src/Log.h +++ b/src/Log.h @@ -60,6 +60,7 @@ class Logger { } \ } while (0) +#undef ERROR #define ERROR(x) LOG(NT_LOG_ERROR, x) #define WARNING(x) LOG(NT_LOG_WARNING, x) #define INFO(x) LOG(NT_LOG_INFO, x) diff --git a/src/Storage.cpp b/src/Storage.cpp index 38709c1fdf..f9966af254 100644 --- a/src/Storage.cpp +++ b/src/Storage.cpp @@ -7,6 +7,7 @@ #include "Storage.h" +#include #include #include @@ -567,7 +568,8 @@ static void WriteString(std::ostream& os, llvm::StringRef str) { void Storage::SavePersistent(std::ostream& os) const { // copy values out of storage as quickly as possible so lock isn't held - std::vector>> entries; + typedef std::pair> NewEntry; + std::vector entries; { std::lock_guard lock(m_mutex); entries.reserve(m_entries.size()); @@ -581,7 +583,7 @@ void Storage::SavePersistent(std::ostream& os) const { // sort in name order std::sort(entries.begin(), entries.end(), - [](const auto& a, const auto& b) { return a.first < b.first; }); + [](const NewEntry& a, const NewEntry& b) { return a.first < b.first; }); std::string base64_encoded; diff --git a/src/networktables/NetworkTable.cpp b/src/networktables/NetworkTable.cpp index 689c7f7a64..8c68b1ed52 100644 --- a/src/networktables/NetworkTable.cpp +++ b/src/networktables/NetworkTable.cpp @@ -92,7 +92,7 @@ void NetworkTable::AddTableListener(StringRef key, void NetworkTable::RemoveTableListener(ITableListener* listener) { auto matches_begin = std::remove_if(m_listeners.begin(), m_listeners.end(), - [=](const auto& x) { return x.first == listener; }); + [=](const Listener& x) { return x.first == listener; }); for (auto i = matches_begin; i != m_listeners.end(); ++i) nt::RemoveEntryListener(i->second); diff --git a/test/unit/leb128Test.cpp b/test/unit/leb128Test.cpp index 5d90ad56e3..7019eb7713 100644 --- a/test/unit/leb128Test.cpp +++ b/test/unit/leb128Test.cpp @@ -18,6 +18,7 @@ #include "gtest/gtest.h" +#include #include #include "llvm/StringRef.h"