mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Update for C++17 and fix MSVC warnings (#1694)
* Update MSVC arguments * Fix json allocator * Fix simulation diamond * Bump gtest * Remove empty varargs in unit tests * Replace test case with test suite * Remove deprecation warning in optional * Remove need for NOMIXMAX to be defined in wpilib headers
This commit is contained in:
committed by
Peter Johnson
parent
fb1239a2ad
commit
221011494d
@@ -27,6 +27,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||
#include <WinSock2.h>
|
||||
#include <Ws2tcpip.h>
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
@@ -53,7 +54,7 @@ TCPAcceptor::TCPAcceptor(int port, const char* address, Logger& logger)
|
||||
#ifdef _WIN32
|
||||
WSAData wsaData;
|
||||
WORD wVersionRequested = MAKEWORD(2, 2);
|
||||
WSAStartup(wVersionRequested, &wsaData);
|
||||
(void)WSAStartup(wVersionRequested, &wsaData);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -151,9 +152,7 @@ void TCPAcceptor::shutdown() {
|
||||
return;
|
||||
address.sin_port = htons(m_port);
|
||||
|
||||
fd_set sdset;
|
||||
struct timeval tv;
|
||||
int result = -1, valopt, sd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
int result = -1, sd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sd < 0) return;
|
||||
|
||||
// Set socket to non-blocking
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -228,7 +228,7 @@ void WebSocket::StartClient(const Twine& uri, const Twine& host,
|
||||
});
|
||||
|
||||
// Start handshake timer if a timeout was specified
|
||||
if (options.handshakeTimeout != uv::Timer::Time::max()) {
|
||||
if (options.handshakeTimeout != (uv::Timer::Time::max)()) {
|
||||
auto timer = uv::Timer::Create(m_stream.GetLoopRef());
|
||||
timer->timeout.connect(
|
||||
[this]() { Terminate(1006, "connection timed out"); });
|
||||
@@ -335,7 +335,7 @@ void WebSocket::HandleIncoming(uv::Buffer& buf, size_t size) {
|
||||
if (m_frameSize == UINT64_MAX) {
|
||||
// Need at least two bytes to determine header length
|
||||
if (m_header.size() < 2u) {
|
||||
size_t toCopy = std::min(2u - m_header.size(), data.size());
|
||||
size_t toCopy = (std::min)(2u - m_header.size(), data.size());
|
||||
m_header.append(data.bytes_begin(), data.bytes_begin() + toCopy);
|
||||
data = data.drop_front(toCopy);
|
||||
if (m_header.size() < 2u) return; // need more data
|
||||
@@ -362,7 +362,7 @@ void WebSocket::HandleIncoming(uv::Buffer& buf, size_t size) {
|
||||
|
||||
// Need to complete header to calculate message size
|
||||
if (m_header.size() < m_headerSize) {
|
||||
size_t toCopy = std::min(m_headerSize - m_header.size(), data.size());
|
||||
size_t toCopy = (std::min)(m_headerSize - m_header.size(), data.size());
|
||||
m_header.append(data.bytes_begin(), data.bytes_begin() + toCopy);
|
||||
data = data.drop_front(toCopy);
|
||||
if (m_header.size() < m_headerSize) return; // need more data
|
||||
@@ -394,7 +394,7 @@ void WebSocket::HandleIncoming(uv::Buffer& buf, size_t size) {
|
||||
|
||||
if (m_frameSize != UINT64_MAX) {
|
||||
size_t need = m_frameStart + m_frameSize - m_payload.size();
|
||||
size_t toCopy = std::min(need, data.size());
|
||||
size_t toCopy = (std::min)(need, data.size());
|
||||
m_payload.append(data.bytes_begin(), data.bytes_begin() + toCopy);
|
||||
data = data.drop_front(toCopy);
|
||||
need -= toCopy;
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable : 4018 26451)
|
||||
#endif
|
||||
|
||||
#ifndef ULLONG_MAX
|
||||
# define ULLONG_MAX ((uint64_t) -1) /* 2^64-1 */
|
||||
#endif
|
||||
|
||||
@@ -142,24 +142,24 @@ void json::json_value::destroy(value_t t) noexcept
|
||||
case value_t::object:
|
||||
{
|
||||
std::allocator<object_t> alloc;
|
||||
alloc.destroy(object);
|
||||
alloc.deallocate(object, 1);
|
||||
std::allocator_traits<decltype(alloc)>::destroy(alloc, object);
|
||||
std::allocator_traits<decltype(alloc)>::deallocate(alloc, object, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
case value_t::array:
|
||||
{
|
||||
std::allocator<array_t> alloc;
|
||||
alloc.destroy(array);
|
||||
alloc.deallocate(array, 1);
|
||||
std::allocator_traits<decltype(alloc)>::destroy(alloc, array);
|
||||
std::allocator_traits<decltype(alloc)>::deallocate(alloc, array, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
case value_t::string:
|
||||
{
|
||||
std::allocator<std::string> alloc;
|
||||
alloc.destroy(string);
|
||||
alloc.deallocate(string, 1);
|
||||
std::allocator_traits<decltype(alloc)>::destroy(alloc, string);
|
||||
std::allocator_traits<decltype(alloc)>::deallocate(alloc, string, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -621,8 +621,8 @@ json::size_type json::max_size() const noexcept
|
||||
|
||||
case value_t::object:
|
||||
{
|
||||
// delegate call to std::allocator<json>::max_size()
|
||||
return std::allocator<json>().max_size();
|
||||
// delegate call to std::allocator<object_t>::max_size()
|
||||
return std::allocator_traits<object_t>::max_size(*m_value.object);
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
@@ -41,6 +41,8 @@ typedef int errno_t;
|
||||
#ifdef _MSC_VER
|
||||
# pragma comment(lib, "shell32.lib")
|
||||
# pragma comment(lib, "ole32.lib")
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4244 4267 4146)
|
||||
#endif
|
||||
|
||||
using namespace wpi;
|
||||
@@ -963,3 +965,7 @@ std::error_code UTF16ToCurCP(const wchar_t *utf16, size_t utf16_len,
|
||||
} // end namespace windows
|
||||
} // end namespace sys
|
||||
} // end namespace wpi
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifdef _WIN32
|
||||
#define _CRT_NONSTDC_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include "wpi/raw_ostream.h"
|
||||
#include "wpi/STLExtras.h"
|
||||
#include "wpi/SmallString.h"
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2015-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#define _CRT_NONSTDC_NO_WARNINGS
|
||||
|
||||
#include "wpi/raw_istream.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -23,7 +23,7 @@ void raw_uv_ostream::write_impl(const char* data, size_t len) {
|
||||
assert(m_left != 0);
|
||||
}
|
||||
|
||||
size_t amt = std::min(m_left, len);
|
||||
size_t amt = (std::min)(m_left, len);
|
||||
auto& buf = m_bufs.back();
|
||||
std::memcpy(buf.base + buf.len, data, amt);
|
||||
data += amt;
|
||||
|
||||
Reference in New Issue
Block a user