diff --git a/cscore/src/main/native/include/cscore_cpp.h b/cscore/src/main/native/include/cscore_cpp.h index 5f71be6948..3f52dcc378 100644 --- a/cscore/src/main/native/include/cscore_cpp.h +++ b/cscore/src/main/native/include/cscore_cpp.h @@ -21,6 +21,12 @@ #include "cscore_c.h" +#ifdef _WIN32 +// Disable uninitialized variable warnings +#pragma warning(push) +#pragma warning(disable : 26495) +#endif + namespace wpi { class json; } // namespace wpi @@ -422,4 +428,9 @@ std::vector GetNetworkInterfaces(); } // namespace cs +#ifdef _WIN32 +// Disable uninitialized variable warnings +#pragma warning(pop) +#endif + #endif // CSCORE_CSCORE_CPP_H_ diff --git a/cscore/src/main/native/include/cscore_oo.h b/cscore/src/main/native/include/cscore_oo.h index 70fd2a09cc..5ab0f70fb0 100644 --- a/cscore/src/main/native/include/cscore_oo.h +++ b/cscore/src/main/native/include/cscore_oo.h @@ -51,7 +51,7 @@ class VideoProperty { kEnum = CS_PROP_ENUM }; - VideoProperty() : m_handle(0), m_kind(kNone) {} + VideoProperty() : m_status(0), m_handle(0), m_kind(kNone) {} std::string GetName() const; diff --git a/cscore/src/main/native/include/cscore_oo.inl b/cscore/src/main/native/include/cscore_oo.inl index 92ff5b77a8..ffd2b23004 100644 --- a/cscore/src/main/native/include/cscore_oo.inl +++ b/cscore/src/main/native/include/cscore_oo.inl @@ -76,7 +76,7 @@ inline VideoProperty::VideoProperty(CS_Property handle) : m_handle(handle) { } inline VideoProperty::VideoProperty(CS_Property handle, Kind kind) - : m_handle(handle), m_kind(kind) {} + : m_status(0), m_handle(handle), m_kind(kind) {} inline VideoSource::VideoSource(const VideoSource& source) : m_handle(source.m_handle == 0 ? 0 diff --git a/cscore/src/main/native/windows/UsbCameraImpl.cpp b/cscore/src/main/native/windows/UsbCameraImpl.cpp index 9fc87f4a69..141ebbedc1 100644 --- a/cscore/src/main/native/windows/UsbCameraImpl.cpp +++ b/cscore/src/main/native/windows/UsbCameraImpl.cpp @@ -54,6 +54,8 @@ #pragma comment(lib, "Mfreadwrite.lib") #pragma comment(lib, "Shlwapi.lib") +#pragma warning(disable : 4996 4018 26451) + static constexpr int NewImageMessage = 0x0400 + 4488; static constexpr int SetCameraMessage = 0x0400 + 254; static constexpr int WaitForStartupMessage = 0x0400 + 294; @@ -76,6 +78,7 @@ UsbCameraImpl::UsbCameraImpl(const wpi::Twine& name, wpi::Logger& logger, : SourceImpl{name, logger, notifier, telemetry}, m_path{path.str()} { std::wstring_convert> utf8_conv; m_widePath = utf8_conv.from_bytes(m_path.c_str()); + m_deviceId = -1; StartMessagePump(); } @@ -679,7 +682,7 @@ void UsbCameraImpl::DeviceCacheProperty( } NotifyPropertyCreated(*rawIndex, *rawPropPtr); - if (perPropPtr) NotifyPropertyCreated(*perIndex, *perPropPtr); + if (perPropPtr && perIndex) NotifyPropertyCreated(*perIndex, *perPropPtr); } CS_StatusValue UsbCameraImpl::DeviceProcessCommand( @@ -815,7 +818,10 @@ CS_StatusValue UsbCameraImpl::DeviceCmdSetMode( m_currentMode = std::move(newModeType); m_mode = newMode; +#pragma warning(push) +#pragma warning(disable : 26110) lock.unlock(); +#pragma warning(pop) if (m_sourceReader) { DeviceDisconnect(); DeviceConnect(); @@ -969,6 +975,7 @@ std::vector EnumerateUsbCameras(CS_Status* status) { std::wstring_convert> utf8_conv; ComPtr pAttributes; IMFActivate** ppDevices = nullptr; + UINT32 count = 0; // Create an attribute store to specify the enumeration parameters. HRESULT hr = MFCreateAttributes(pAttributes.GetAddressOf(), 1); @@ -984,7 +991,6 @@ std::vector EnumerateUsbCameras(CS_Status* status) { } // Enumerate devices. - UINT32 count; hr = MFEnumDeviceSources(pAttributes.Get(), &ppDevices, &count); if (FAILED(hr)) { goto done; @@ -1000,11 +1006,11 @@ std::vector EnumerateUsbCameras(CS_Status* status) { info.dev = i; WCHAR buf[512]; ppDevices[i]->GetString(MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, buf, - sizeof(buf), NULL); + sizeof(buf) / sizeof(WCHAR), NULL); info.name = utf8_conv.to_bytes(buf); ppDevices[i]->GetString( MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, buf, - sizeof(buf), NULL); + sizeof(buf) / sizeof(WCHAR), NULL); info.path = utf8_conv.to_bytes(buf); retval.emplace_back(std::move(info)); } @@ -1012,12 +1018,15 @@ std::vector EnumerateUsbCameras(CS_Status* status) { done: pAttributes.Reset(); - for (DWORD i = 0; i < count; i++) { - if (ppDevices[i]) { - ppDevices[i]->Release(); - ppDevices[i] = nullptr; + if (ppDevices) { + for (DWORD i = 0; i < count; i++) { + if (ppDevices[i]) { + ppDevices[i]->Release(); + ppDevices[i] = nullptr; + } } } + CoTaskMemFree(ppDevices); return retval; } diff --git a/cscore/src/main/native/windows/UsbCameraImpl.h b/cscore/src/main/native/windows/UsbCameraImpl.h index 12a878d131..11e07aaf0d 100644 --- a/cscore/src/main/native/windows/UsbCameraImpl.h +++ b/cscore/src/main/native/windows/UsbCameraImpl.h @@ -98,7 +98,7 @@ class UsbCameraImpl : public SourceImpl, }; explicit Message(Kind kind_) - : kind(kind_), from(std::this_thread::get_id()) {} + : kind(kind_), data{0}, from(std::this_thread::get_id()) {} Kind kind; int data[4]; diff --git a/cscore/src/main/native/windows/UsbCameraProperty.h b/cscore/src/main/native/windows/UsbCameraProperty.h index 02dfdfe667..11888e9f2d 100644 --- a/cscore/src/main/native/windows/UsbCameraProperty.h +++ b/cscore/src/main/native/windows/UsbCameraProperty.h @@ -68,8 +68,10 @@ class UsbCameraProperty : public PropertyImpl { bool isAutoProp{true}; bool isControlProperty{false}; - tagVideoProcAmpProperty tagVideoProc; - tagCameraControlProperty tagCameraControl; + tagVideoProcAmpProperty tagVideoProc{ + tagVideoProcAmpProperty::VideoProcAmp_Brightness}; + tagCameraControlProperty tagCameraControl{ + tagCameraControlProperty::CameraControl_Pan}; // If this is a percentage (rather than raw) property bool percentage{false}; diff --git a/hal/src/main/native/athena/FRCDriverStation.cpp b/hal/src/main/native/athena/FRCDriverStation.cpp index fbcf27086e..08ea9187b6 100644 --- a/hal/src/main/native/athena/FRCDriverStation.cpp +++ b/hal/src/main/native/athena/FRCDriverStation.cpp @@ -138,7 +138,7 @@ static int32_t HAL_GetJoystickButtonsInternal(int32_t joystickNum, static int32_t HAL_GetJoystickDescriptorInternal(int32_t joystickNum, HAL_JoystickDescriptor* desc) { desc->isXbox = 0; - desc->type = std::numeric_limits::max(); + desc->type = (std::numeric_limits::max)(); desc->name[0] = '\0'; desc->axisCount = HAL_kMaxJoystickAxes; /* set to the desc->axisTypes's capacity */ diff --git a/hal/src/main/native/sim/DigitalInternal.h b/hal/src/main/native/sim/DigitalInternal.h index 89644a17ae..9df4c515af 100644 --- a/hal/src/main/native/sim/DigitalInternal.h +++ b/hal/src/main/native/sim/DigitalInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2016-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. */ @@ -44,11 +44,11 @@ constexpr int32_t kExpectedLoopTiming = 40; * scaling is implemented as an output squelch to get longer periods for old * devices. */ -constexpr float kDefaultPwmPeriod = 5.05; +constexpr float kDefaultPwmPeriod = 5.05f; /** * kDefaultPwmCenter is the PWM range center in ms */ -constexpr float kDefaultPwmCenter = 1.5; +constexpr float kDefaultPwmCenter = 1.5f; /** * kDefaultPWMStepsDown is the number of PWM steps below the centerpoint */ diff --git a/hal/src/main/native/sim/Interrupts.cpp b/hal/src/main/native/sim/Interrupts.cpp index 75247ca7c9..f169e4a91c 100644 --- a/hal/src/main/native/sim/Interrupts.cpp +++ b/hal/src/main/native/sim/Interrupts.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-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. */ @@ -26,6 +26,10 @@ #include "mockdata/DIODataInternal.h" #include "mockdata/HAL_Value.h" +#ifdef _WIN32 +#pragma warning(disable : 4996 4018 6297 26451 4334) +#endif + using namespace hal; enum WaitResult { @@ -54,9 +58,9 @@ struct Interrupt { }; struct SynchronousWaitData { - HAL_InterruptHandle interruptHandle; + HAL_InterruptHandle interruptHandle{HAL_kInvalidHandle}; wpi::condition_variable waitCond; - HAL_Bool waitPredicate; + HAL_Bool waitPredicate{false}; }; } // namespace @@ -231,7 +235,7 @@ static int64_t WaitForInterruptDigital(HAL_InterruptHandle handle, // Cancel our callback SimDIOData[digitalIndex].value.CancelCallback(uid); - synchronousInterruptHandles->Free(dataHandle); + (void)synchronousInterruptHandles->Free(dataHandle); // Check for what to return if (timedOut) return WaitResult::Timeout; @@ -295,7 +299,7 @@ static int64_t WaitForInterruptAnalog(HAL_InterruptHandle handle, // Cancel our callback SimAnalogInData[analogIndex].voltage.CancelCallback(uid); - synchronousInterruptHandles->Free(dataHandle); + (void)synchronousInterruptHandles->Free(dataHandle); // Check for what to return if (timedOut) return WaitResult::Timeout; diff --git a/hal/src/main/native/sim/mockdata/EncoderDataInternal.h b/hal/src/main/native/sim/mockdata/EncoderDataInternal.h index 657d977f9e..2f4894e2c1 100644 --- a/hal/src/main/native/sim/mockdata/EncoderDataInternal.h +++ b/hal/src/main/native/sim/mockdata/EncoderDataInternal.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-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. */ @@ -30,7 +30,7 @@ class EncoderData { SimDataValue initialized{false}; SimDataValue count{0}; SimDataValue period{ - std::numeric_limits::max()}; + (std::numeric_limits::max)()}; SimDataValue reset{false}; SimDataValue maxPeriod{0}; SimDataValue direction{false}; diff --git a/ntcore/src/main/native/cpp/CallbackManager.h b/ntcore/src/main/native/cpp/CallbackManager.h index 0fd9617253..6c2c9cf351 100644 --- a/ntcore/src/main/native/cpp/CallbackManager.h +++ b/ntcore/src/main/native/cpp/CallbackManager.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-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. */ @@ -138,7 +138,8 @@ void CallbackThread::Main() { if (!listener) continue; if (!static_cast(this)->Matches(listener, item.second)) continue; - static_cast(this)->SetListener(&item.second, i); + static_cast(this)->SetListener(&item.second, + static_cast(i)); if (listener.callback) { lock.unlock(); static_cast(this)->DoCallback(listener.callback, diff --git a/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp b/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp index 1ec0942a62..86c0f97f5b 100644 --- a/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp +++ b/ntcore/src/main/native/cpp/networktables/NetworkTable.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-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. */ @@ -21,6 +21,8 @@ using namespace nt; #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif _WIN32 +#pragma warning(disable : 4996) #endif const char NetworkTable::PATH_SEPARATOR_CHAR = '/'; diff --git a/ntcore/src/main/native/include/networktables/NetworkTable.h b/ntcore/src/main/native/include/networktables/NetworkTable.h index 6bc2af6c92..6504e093bf 100644 --- a/ntcore/src/main/native/include/networktables/NetworkTable.h +++ b/ntcore/src/main/native/include/networktables/NetworkTable.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* 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. */ @@ -36,6 +36,9 @@ class NetworkTableInstance; #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif _WIN32 +#pragma warning(push) +#pragma warning(disable : 4996) #endif /** @@ -765,6 +768,8 @@ class NetworkTable final : public ITable { #ifdef __GNUC__ #pragma GCC diagnostic pop +#elif _WIN32 +#pragma warning(pop) #endif } // namespace nt diff --git a/ntcore/src/main/native/include/networktables/NetworkTableValue.h b/ntcore/src/main/native/include/networktables/NetworkTableValue.h index 3aa0c013f5..7b881afdab 100644 --- a/ntcore/src/main/native/include/networktables/NetworkTableValue.h +++ b/ntcore/src/main/native/include/networktables/NetworkTableValue.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* 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. */ @@ -278,21 +278,16 @@ class Value final { return val; } -/** - * Creates a string entry value. - * - * @param value the value - * @param time if nonzero, the creation time to use (instead of the current - * time) - * @return The entry value - */ -#ifdef _MSC_VER - template >> -#else + /** + * Creates a string entry value. + * + * @param value the value + * @param time if nonzero, the creation time to use (instead of the current + * time) + * @return The entry value + */ template ::value>::type> -#endif static std::shared_ptr MakeString(T&& value, uint64_t time = 0) { auto val = std::make_shared(NT_STRING, time, private_init()); val->m_string = std::move(value); @@ -317,21 +312,16 @@ class Value final { return val; } -/** - * Creates a raw entry value. - * - * @param value the value - * @param time if nonzero, the creation time to use (instead of the current - * time) - * @return The entry value - */ -#ifdef _MSC_VER - template >> -#else + /** + * Creates a raw entry value. + * + * @param value the value + * @param time if nonzero, the creation time to use (instead of the current + * time) + * @return The entry value + */ template ::value>::type> -#endif static std::shared_ptr MakeRaw(T&& value, uint64_t time = 0) { auto val = std::make_shared(NT_RAW, time, private_init()); val->m_string = std::move(value); diff --git a/ntcore/src/main/native/include/networktables/RpcCall.h b/ntcore/src/main/native/include/networktables/RpcCall.h index 7d83140496..fc2e0bf569 100644 --- a/ntcore/src/main/native/include/networktables/RpcCall.h +++ b/ntcore/src/main/native/include/networktables/RpcCall.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-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. */ @@ -36,7 +36,7 @@ class RpcCall final { */ RpcCall(NT_Entry entry, NT_RpcCall call) : m_entry(entry), m_call(call) {} - RpcCall(RpcCall&& other); + RpcCall(RpcCall&& other) noexcept; RpcCall(const RpcCall&) = delete; RpcCall& operator=(const RpcCall&) = delete; diff --git a/ntcore/src/main/native/include/networktables/RpcCall.inl b/ntcore/src/main/native/include/networktables/RpcCall.inl index d7dacf5ec2..0e9b52297b 100644 --- a/ntcore/src/main/native/include/networktables/RpcCall.inl +++ b/ntcore/src/main/native/include/networktables/RpcCall.inl @@ -12,7 +12,7 @@ namespace nt { -inline RpcCall::RpcCall(RpcCall&& other) : RpcCall() { +inline RpcCall::RpcCall(RpcCall&& other) noexcept : RpcCall() { swap(*this, other); } diff --git a/ntcore/src/main/native/include/ntcore_cpp.h b/ntcore/src/main/native/include/ntcore_cpp.h index 56cb5afe17..d7e91ad442 100644 --- a/ntcore/src/main/native/include/ntcore_cpp.h +++ b/ntcore/src/main/native/include/ntcore_cpp.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* 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. */ @@ -79,19 +79,19 @@ struct ConnectionInfo { std::string remote_ip; /** The port number of the remote node. */ - unsigned int remote_port; + unsigned int remote_port{0}; /** * The last time any update was received from the remote node (same scale as * returned by nt::Now()). */ - uint64_t last_update; + uint64_t last_update{0}; /** * The protocol version being used for this connection. This in protocol * layer format, so 0x0200 = 2.0, 0x0300 = 3.0). */ - unsigned int protocol_version; + unsigned int protocol_version{0}; friend void swap(ConnectionInfo& first, ConnectionInfo& second) { using std::swap; @@ -179,7 +179,7 @@ class RpcAnswer { /** NetworkTables Entry Notification */ class EntryNotification { public: - EntryNotification() : listener(0), entry(0) {} + EntryNotification() : listener(0), entry(0), flags(0) {} EntryNotification(NT_EntryListener listener_, NT_Entry entry_, StringRef name_, std::shared_ptr value_, unsigned int flags_) diff --git a/ntcore/src/main/native/include/tables/ITableListener.h b/ntcore/src/main/native/include/tables/ITableListener.h index e836b515a7..dae6f853a8 100644 --- a/ntcore/src/main/native/include/tables/ITableListener.h +++ b/ntcore/src/main/native/include/tables/ITableListener.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-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. */ @@ -18,6 +18,9 @@ #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif _WIN32 +#pragma warning(push) +#pragma warning(disable : 4996) #endif class ITable; @@ -58,6 +61,8 @@ class WPI_DEPRECATED( #ifdef __GNUC__ #pragma GCC diagnostic pop +#elif _WIN32 +#pragma warning(pop) #endif #endif // NTCORE_TABLES_ITABLELISTENER_H_ diff --git a/ntcore/src/test/native/cpp/StorageTest.cpp b/ntcore/src/test/native/cpp/StorageTest.cpp index eb04738245..f271123f69 100644 --- a/ntcore/src/test/native/cpp/StorageTest.cpp +++ b/ntcore/src/test/native/cpp/StorageTest.cpp @@ -981,13 +981,13 @@ TEST_P(StorageTestPopulateOne, DeletedGetEntries) { EXPECT_TRUE(storage.GetEntries("", 0).empty()); } -INSTANTIATE_TEST_CASE_P(StorageTestsEmpty, StorageTestEmpty, - ::testing::Bool(), ); -INSTANTIATE_TEST_CASE_P(StorageTestsPopulateOne, StorageTestPopulateOne, - ::testing::Bool(), ); -INSTANTIATE_TEST_CASE_P(StorageTestsPopulated, StorageTestPopulated, - ::testing::Bool(), ); -INSTANTIATE_TEST_CASE_P(StorageTestsPersistent, StorageTestPersistent, - ::testing::Bool(), ); +INSTANTIATE_TEST_SUITE_P(StorageTestsEmpty, StorageTestEmpty, + ::testing::Bool()); +INSTANTIATE_TEST_SUITE_P(StorageTestsPopulateOne, StorageTestPopulateOne, + ::testing::Bool()); +INSTANTIATE_TEST_SUITE_P(StorageTestsPopulated, StorageTestPopulated, + ::testing::Bool()); +INSTANTIATE_TEST_SUITE_P(StorageTestsPersistent, StorageTestPersistent, + ::testing::Bool()); } // namespace nt diff --git a/ntcore/src/test/native/cpp/WireDecoderTest.cpp b/ntcore/src/test/native/cpp/WireDecoderTest.cpp index a13fa7a275..e32f9099fa 100644 --- a/ntcore/src/test/native/cpp/WireDecoderTest.cpp +++ b/ntcore/src/test/native/cpp/WireDecoderTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* 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. */ diff --git a/ntcore/src/test/native/cpp/WireEncoderTest.cpp b/ntcore/src/test/native/cpp/WireEncoderTest.cpp index 664344fae9..fab5a22ddb 100644 --- a/ntcore/src/test/native/cpp/WireEncoderTest.cpp +++ b/ntcore/src/test/native/cpp/WireEncoderTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* 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. */ diff --git a/shared/config.gradle b/shared/config.gradle index 02c2b68799..055af89838 100644 --- a/shared/config.gradle +++ b/shared/config.gradle @@ -1,8 +1,8 @@ import edu.wpi.first.nativeutils.* import org.gradle.internal.os.OperatingSystem -def windowsCompilerArgs = ['/EHsc', '/DNOMINMAX', '/Zi', '/FS', '/Zc:inline', '/MP4'] -def windowsCCompilerArgs = ['/Zi', '/FS', '/Zc:inline'] +def windowsCompilerArgs = ['/EHsc', '/D_CRT_SECURE_NO_WARNINGS', '/Zi', '/FS', '/Zc:inline', '/MP4', '/W3', '/wd4244', '/wd4267', '/wd4146', '/std:c++17', '/permissive-', '/WX'] +def windowsCCompilerArgs = ['/Zi', '/FS', '/Zc:inline', '/W3', '/WX'] def windowsReleaseCompilerArgs = ['/O2', '/MD'] def windowsDebugCompilerArgs = ['/Od', '/MDd'] def windowsLinkerArgs = ['/DEBUG:FULL'] diff --git a/shared/googletest.gradle b/shared/googletest.gradle index 736d886e4c..893c17c73b 100644 --- a/shared/googletest.gradle +++ b/shared/googletest.gradle @@ -5,7 +5,7 @@ model { artifactId = 'googletest' headerClassifier = 'headers' ext = 'zip' - version = '1.8.0-4-4e4df22' + version = '1.8.1-1-f71fb4f' sharedConfigs = [:] staticConfigs = project.staticGtestConfigs } diff --git a/simulation/halsim_adx_gyro_accelerometer/src/main/native/cpp/ADXRS450_SpiGyroWrapperData.cpp b/simulation/halsim_adx_gyro_accelerometer/src/main/native/cpp/ADXRS450_SpiGyroWrapperData.cpp index 5658b30ac4..d12a034695 100644 --- a/simulation/halsim_adx_gyro_accelerometer/src/main/native/cpp/ADXRS450_SpiGyroWrapperData.cpp +++ b/simulation/halsim_adx_gyro_accelerometer/src/main/native/cpp/ADXRS450_SpiGyroWrapperData.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-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. */ @@ -31,7 +31,7 @@ const int ADXRS450_SpiGyroWrapper::kPacketSize = 4 + 1; // +1 for timestamp template constexpr const T& clamp(const T& value, const T& low, const T& high) { - return std::max(low, std::min(value, high)); + return (std::max)(low, (std::min)(value, high)); } static void ADXRS450SPI_ReadBufferCallback(const char* name, void* param, diff --git a/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXL345_I2CAccelerometerTest.cpp b/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXL345_I2CAccelerometerTest.cpp index aa5886180f..8895ee3086 100644 --- a/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXL345_I2CAccelerometerTest.cpp +++ b/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXL345_I2CAccelerometerTest.cpp @@ -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. */ @@ -41,7 +41,6 @@ TEST_P(ADXL345_I2CAccelerometerTest, TestAccelerometer) { EXPECT_NEAR(0.11, accel.GetZ(), EPSILON); } -INSTANTIATE_TEST_CASE_P(ADXL345_I2CAccelerometerTest, - ADXL345_I2CAccelerometerTest, - ::testing::Values(frc::I2C::kOnboard, - frc::I2C::kMXP), ); +INSTANTIATE_TEST_SUITE_P(ADXL345_I2CAccelerometerTest, + ADXL345_I2CAccelerometerTest, + ::testing::Values(frc::I2C::kOnboard, frc::I2C::kMXP)); diff --git a/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXL345_SpiAccelerometerTest.cpp b/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXL345_SpiAccelerometerTest.cpp index 548240d106..8cf0727759 100644 --- a/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXL345_SpiAccelerometerTest.cpp +++ b/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXL345_SpiAccelerometerTest.cpp @@ -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. */ @@ -41,8 +41,8 @@ TEST_P(ADXL345_SpiAccelerometerTest, TestAccelerometer) { EXPECT_NEAR(0.11, accel.GetZ(), EPSILON); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( ADXL345_SpiAccelerometerTest, ADXL345_SpiAccelerometerTest, ::testing::Values(frc::SPI::kOnboardCS0, frc::SPI::kOnboardCS1, frc::SPI::kOnboardCS2, frc::SPI::kOnboardCS3, - frc::SPI::kMXP), ); + frc::SPI::kMXP)); diff --git a/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXL362_SpiAccelerometerTest.cpp b/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXL362_SpiAccelerometerTest.cpp index 67efd18b22..d038419eb9 100644 --- a/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXL362_SpiAccelerometerTest.cpp +++ b/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXL362_SpiAccelerometerTest.cpp @@ -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. */ @@ -41,8 +41,8 @@ TEST_P(ADXL362_SpiAccelerometerTest, TestAccelerometer) { EXPECT_NEAR(0.11, accel.GetZ(), EPSILON); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( ADXL362_SpiAccelerometerTest, ADXL362_SpiAccelerometerTest, ::testing::Values(frc::SPI::kOnboardCS0, frc::SPI::kOnboardCS1, frc::SPI::kOnboardCS2, frc::SPI::kOnboardCS3, - frc::SPI::kMXP), ); + frc::SPI::kMXP)); diff --git a/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXRS450_SpiGyroWrapperTest.cpp b/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXRS450_SpiGyroWrapperTest.cpp index f1c14ca613..09d748ba7d 100644 --- a/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXRS450_SpiGyroWrapperTest.cpp +++ b/simulation/halsim_adx_gyro_accelerometer/src/test/native/cpp/ADXRS450_SpiGyroWrapperTest.cpp @@ -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. */ @@ -34,8 +34,8 @@ TEST_P(ADXRS450_SpiGyroWrapperTest, TestAccelerometer) { #endif } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( ADXRS450_SpiGyroWrapperTest, ADXRS450_SpiGyroWrapperTest, ::testing::Values(frc::SPI::kOnboardCS0, frc::SPI::kOnboardCS1, frc::SPI::kOnboardCS2, frc::SPI::kOnboardCS3, - frc::SPI::kMXP), ); + frc::SPI::kMXP)); diff --git a/simulation/halsim_ds_socket/src/main/native/cpp/main.cpp b/simulation/halsim_ds_socket/src/main/native/cpp/main.cpp index 94be5cbb2a..7d683b3e3f 100644 --- a/simulation/halsim_ds_socket/src/main/native/cpp/main.cpp +++ b/simulation/halsim_ds_socket/src/main/native/cpp/main.cpp @@ -40,7 +40,7 @@ static std::unique_ptr singleByte; namespace { struct DataStore { wpi::SmallVector m_frame; - size_t m_frameSize = std::numeric_limits::max(); + size_t m_frameSize = (std::numeric_limits::max)(); halsim::DSCommPacket* dsPacket; }; } // namespace @@ -53,9 +53,9 @@ static SimpleBufferPool<4>& GetBufferPool() { static void HandleTcpDataStream(Buffer& buf, size_t size, DataStore& store) { wpi::StringRef data{buf.base, size}; while (!data.empty()) { - if (store.m_frameSize == std::numeric_limits::max()) { + if (store.m_frameSize == (std::numeric_limits::max)()) { if (store.m_frame.size() < 2u) { - size_t toCopy = std::min(2u - store.m_frame.size(), data.size()); + size_t toCopy = (std::min)(2u - store.m_frame.size(), data.size()); store.m_frame.append(data.bytes_begin(), data.bytes_begin() + toCopy); data = data.drop_front(toCopy); if (store.m_frame.size() < 2u) return; // need more data @@ -63,9 +63,9 @@ static void HandleTcpDataStream(Buffer& buf, size_t size, DataStore& store) { store.m_frameSize = (static_cast(store.m_frame[0]) << 8) | static_cast(store.m_frame[1]); } - if (store.m_frameSize != std::numeric_limits::max()) { + if (store.m_frameSize != (std::numeric_limits::max)()) { size_t need = store.m_frameSize - (store.m_frame.size() - 2); - size_t toCopy = std::min(need, data.size()); + size_t toCopy = (std::min)(need, data.size()); store.m_frame.append(data.bytes_begin(), data.bytes_begin() + toCopy); data = data.drop_front(toCopy); need -= toCopy; @@ -73,7 +73,7 @@ static void HandleTcpDataStream(Buffer& buf, size_t size, DataStore& store) { auto ds = store.dsPacket; ds->DecodeTCP(store.m_frame); store.m_frame.clear(); - store.m_frameSize = std::numeric_limits::max(); + store.m_frameSize = (std::numeric_limits::max)(); } } } diff --git a/simulation/halsim_ds_socket/src/test/native/cpp/main.cpp b/simulation/halsim_ds_socket/src/test/native/cpp/main.cpp index aa4f4b0e85..fd8f022427 100644 --- a/simulation/halsim_ds_socket/src/test/native/cpp/main.cpp +++ b/simulation/halsim_ds_socket/src/test/native/cpp/main.cpp @@ -1,17 +1,17 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2015-2018 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. */ -/*----------------------------------------------------------------------------*/ - -#include - -#include "gtest/gtest.h" - -int main(int argc, char** argv) { - HAL_Initialize(500, 0); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} +/*----------------------------------------------------------------------------*/ +/* 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. */ +/*----------------------------------------------------------------------------*/ + +#include + +#include "gtest/gtest.h" + +int main(int argc, char** argv) { + HAL_Initialize(500, 0); + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); + return ret; +} diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/AccelerometerSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/AccelerometerSim.h index fc9a456f48..041f257585 100644 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/AccelerometerSim.h +++ b/simulation/lowfi_simulation/src/main/native/include/lowfisim/AccelerometerSim.h @@ -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. */ @@ -7,13 +7,13 @@ #pragma once -#include "lowfisim/SimulatorComponent.h" +#include "lowfisim/SimulatorComponentBase.h" namespace frc { namespace sim { namespace lowfi { -class AccelerometerSim : public virtual SimulatorComponent { +class AccelerometerSim : public SimulatorComponentBase { public: virtual double GetAcceleration() = 0; virtual void SetAcceleration(double acceleration) = 0; diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/EncoderSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/EncoderSim.h index a16f94ce23..2e14755c53 100644 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/EncoderSim.h +++ b/simulation/lowfi_simulation/src/main/native/include/lowfisim/EncoderSim.h @@ -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. */ @@ -7,13 +7,13 @@ #pragma once -#include "lowfisim/SimulatorComponent.h" +#include "lowfisim/SimulatorComponentBase.h" namespace frc { namespace sim { namespace lowfi { -class EncoderSim : public virtual SimulatorComponent { +class EncoderSim : public SimulatorComponentBase { public: virtual void SetPosition(double position) = 0; virtual void SetVelocity(double velocity) = 0; diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/GyroSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/GyroSim.h index dcaa28ff06..bc805985d9 100644 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/GyroSim.h +++ b/simulation/lowfi_simulation/src/main/native/include/lowfisim/GyroSim.h @@ -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. */ @@ -7,13 +7,13 @@ #pragma once -#include "lowfisim/SimulatorComponent.h" +#include "lowfisim/SimulatorComponentBase.h" namespace frc { namespace sim { namespace lowfi { -class GyroSim : public virtual SimulatorComponent { +class GyroSim : public SimulatorComponentBase { public: virtual void SetAngle(double angle) = 0; virtual double GetAngle() = 0; diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/MotorSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/MotorSim.h index e88004878c..77532a68b1 100644 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/MotorSim.h +++ b/simulation/lowfi_simulation/src/main/native/include/lowfisim/MotorSim.h @@ -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. */ @@ -7,13 +7,13 @@ #pragma once -#include "lowfisim/SimulatorComponent.h" +#include "lowfisim/SimulatorComponentBase.h" namespace frc { namespace sim { namespace lowfi { -class MotorSim : public virtual SimulatorComponent { +class MotorSim : public SimulatorComponentBase { public: virtual double GetPosition() const = 0; virtual double GetVelocity() const = 0; diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimpleAccelerometerSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimpleAccelerometerSim.h index 4c10cfe8cd..482ac11b03 100644 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimpleAccelerometerSim.h +++ b/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimpleAccelerometerSim.h @@ -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. */ @@ -10,17 +10,13 @@ #include #include "lowfisim/AccelerometerSim.h" -#include "lowfisim/SimulatorComponentBase.h" namespace frc { namespace sim { namespace lowfi { -class SimpleAccelerometerSim : public SimulatorComponentBase, - public AccelerometerSim { +class SimpleAccelerometerSim : public AccelerometerSim { public: - using SimulatorComponentBase::GetDisplayName; - SimpleAccelerometerSim(const std::function& initializedFunction, const std::function& setterFunction, const std::function& getterFunction) diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/ADXRS450_SpiGyroSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/ADXRS450_SpiGyroSim.h index 9b23320a7e..1c5e7bfc1f 100644 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/ADXRS450_SpiGyroSim.h +++ b/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/ADXRS450_SpiGyroSim.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-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. */ @@ -9,13 +9,12 @@ #include "ADXRS450_SpiGyroWrapperData.h" #include "lowfisim/GyroSim.h" -#include "lowfisim/SimulatorComponentBase.h" namespace frc { namespace sim { namespace lowfi { -class ADXRS450_SpiGyroSim : public SimulatorComponentBase, public GyroSim { +class ADXRS450_SpiGyroSim : public GyroSim { public: explicit ADXRS450_SpiGyroSim(int spiPort); diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiAnalogGyroSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiAnalogGyroSim.h index 8741cb2454..a5957ef40d 100644 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiAnalogGyroSim.h +++ b/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiAnalogGyroSim.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-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. */ @@ -8,14 +8,13 @@ #pragma once #include "lowfisim/GyroSim.h" -#include "lowfisim/SimulatorComponentBase.h" #include "simulation/AnalogGyroSim.h" namespace frc { namespace sim { namespace lowfi { -class WpiAnalogGyroSim : public SimulatorComponentBase, public GyroSim { +class WpiAnalogGyroSim : public GyroSim { public: explicit WpiAnalogGyroSim(int index); diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiEncoderSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiEncoderSim.h index 6460d8b96c..0c936e5bc0 100644 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiEncoderSim.h +++ b/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiEncoderSim.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-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. */ @@ -8,14 +8,13 @@ #pragma once #include "lowfisim/EncoderSim.h" -#include "lowfisim/SimulatorComponentBase.h" #include "simulation/EncoderSim.h" namespace frc { namespace sim { namespace lowfi { -class WpiEncoderSim : public SimulatorComponentBase, public EncoderSim { +class WpiEncoderSim : public EncoderSim { public: explicit WpiEncoderSim(int index); bool IsWrapperInitialized() const override; diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiMotorSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiMotorSim.h index d24e8313aa..9323aecf85 100644 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiMotorSim.h +++ b/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiMotorSim.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-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. */ @@ -8,7 +8,6 @@ #pragma once #include "lowfisim/MotorSim.h" -#include "lowfisim/SimulatorComponentBase.h" #include "lowfisim/motormodel/MotorModel.h" #include "simulation/PWMSim.h" @@ -16,7 +15,7 @@ namespace frc { namespace sim { namespace lowfi { -class WpiMotorSim : public SimulatorComponentBase, public MotorSim { +class WpiMotorSim : public MotorSim { public: explicit WpiMotorSim(int index, MotorModel& motorModelSimulator); bool IsWrapperInitialized() const override; diff --git a/wpilibc/src/main/native/cpp/RobotBase.cpp b/wpilibc/src/main/native/cpp/RobotBase.cpp index bc316f4d32..8cf0633232 100644 --- a/wpilibc/src/main/native/cpp/RobotBase.cpp +++ b/wpilibc/src/main/native/cpp/RobotBase.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-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. */ @@ -118,8 +118,9 @@ RobotBase::RobotBase() : m_ds(DriverStation::GetInstance()) { LiveWindow::GetInstance()->SetEnabled(false); } -RobotBase::RobotBase(RobotBase&&) : m_ds(DriverStation::GetInstance()) {} +RobotBase::RobotBase(RobotBase&&) noexcept + : m_ds(DriverStation::GetInstance()) {} RobotBase::~RobotBase() { cs::Shutdown(); } -RobotBase& RobotBase::operator=(RobotBase&&) { return *this; } +RobotBase& RobotBase::operator=(RobotBase&&) noexcept { return *this; } diff --git a/wpilibc/src/main/native/include/frc/RobotBase.h b/wpilibc/src/main/native/include/frc/RobotBase.h index eee07d66f7..185f00e958 100644 --- a/wpilibc/src/main/native/include/frc/RobotBase.h +++ b/wpilibc/src/main/native/include/frc/RobotBase.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-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. */ @@ -131,8 +131,8 @@ class RobotBase { // m_ds isn't moved in these because DriverStation is a singleton; every // instance of RobotBase has a reference to the same object. - RobotBase(RobotBase&&); - RobotBase& operator=(RobotBase&&); + RobotBase(RobotBase&&) noexcept; + RobotBase& operator=(RobotBase&&) noexcept; DriverStation& m_ds; diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardLayout.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardLayout.h index 0b5d459371..e7baec993b 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardLayout.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardLayout.h @@ -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. */ @@ -16,6 +16,11 @@ #include "frc/shuffleboard/ShuffleboardContainer.h" #include "frc/smartdashboard/Sendable.h" +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + namespace frc { /** @@ -33,3 +38,7 @@ class ShuffleboardLayout : public ShuffleboardComponent, }; } // namespace frc + +#ifdef _WIN32 +#pragma warning(pop) +#endif diff --git a/wpilibc/src/test/native/cpp/FilterNoiseTest.cpp b/wpilibc/src/test/native/cpp/FilterNoiseTest.cpp index ea14f32f8d..86bb42c55d 100644 --- a/wpilibc/src/test/native/cpp/FilterNoiseTest.cpp +++ b/wpilibc/src/test/native/cpp/FilterNoiseTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* 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. */ @@ -133,5 +133,5 @@ TEST_P(FilterNoiseTest, NoiseReduce) { << "Filter should have reduced noise accumulation but failed"; } -INSTANTIATE_TEST_CASE_P(Test, FilterNoiseTest, - testing::Values(TEST_SINGLE_POLE_IIR, TEST_MOVAVG), ); +INSTANTIATE_TEST_SUITE_P(Test, FilterNoiseTest, + testing::Values(TEST_SINGLE_POLE_IIR, TEST_MOVAVG)); diff --git a/wpilibc/src/test/native/cpp/FilterOutputTest.cpp b/wpilibc/src/test/native/cpp/FilterOutputTest.cpp index ec71760998..4cb0973d27 100644 --- a/wpilibc/src/test/native/cpp/FilterOutputTest.cpp +++ b/wpilibc/src/test/native/cpp/FilterOutputTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* 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. */ @@ -152,6 +152,6 @@ TEST_P(FilterOutputTest, FilterOutput) { << "Filter output didn't match expected value"; } -INSTANTIATE_TEST_CASE_P(Test, FilterOutputTest, - testing::Values(TEST_SINGLE_POLE_IIR, TEST_HIGH_PASS, - TEST_MOVAVG, TEST_PULSE), ); +INSTANTIATE_TEST_SUITE_P(Test, FilterOutputTest, + testing::Values(TEST_SINGLE_POLE_IIR, TEST_HIGH_PASS, + TEST_MOVAVG, TEST_PULSE)); diff --git a/wpilibc/src/test/native/cpp/SpeedControllerGroupTest.cpp b/wpilibc/src/test/native/cpp/SpeedControllerGroupTest.cpp index a6f50285f9..cb81fc9cfc 100644 --- a/wpilibc/src/test/native/cpp/SpeedControllerGroupTest.cpp +++ b/wpilibc/src/test/native/cpp/SpeedControllerGroupTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-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. */ @@ -132,5 +132,5 @@ TEST_P(SpeedControllerGroupTest, PIDWrite) { } } -INSTANTIATE_TEST_CASE_P(Test, SpeedControllerGroupTest, - testing::Values(TEST_ONE, TEST_TWO, TEST_THREE), ); +INSTANTIATE_TEST_SUITE_P(Test, SpeedControllerGroupTest, + testing::Values(TEST_ONE, TEST_TWO, TEST_THREE)); diff --git a/wpilibcExamples/build.gradle b/wpilibcExamples/build.gradle index 3c8720385a..af1b25af9c 100644 --- a/wpilibcExamples/build.gradle +++ b/wpilibcExamples/build.gradle @@ -140,6 +140,8 @@ model { binary.tasks.withType(CppCompile) { if (!(binary.toolChain in VisualCpp)) { cppCompiler.args "-Wno-error=deprecated-declarations" + } else { + cppCompiler.args "/wd4996" } } if (binary.targetPlatform.architecture.name != 'athena') { diff --git a/wpilibcIntegrationTests/src/main/native/cpp/MotorEncoderTest.cpp b/wpilibcIntegrationTests/src/main/native/cpp/MotorEncoderTest.cpp index e750f888e5..a5b33de28e 100644 --- a/wpilibcIntegrationTests/src/main/native/cpp/MotorEncoderTest.cpp +++ b/wpilibcIntegrationTests/src/main/native/cpp/MotorEncoderTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2014-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2014-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. */ @@ -189,6 +189,5 @@ TEST_P(MotorEncoderTest, Reset) { EXPECT_EQ(0, m_encoder->Get()) << "Encoder did not reset to 0"; } -INSTANTIATE_TEST_CASE_P(Test, MotorEncoderTest, - testing::Values(TEST_VICTOR, TEST_JAGUAR, - TEST_TALON), ); +INSTANTIATE_TEST_SUITE_P(Test, MotorEncoderTest, + testing::Values(TEST_VICTOR, TEST_JAGUAR, TEST_TALON)); diff --git a/wpilibcIntegrationTests/src/main/native/cpp/MotorInvertingTest.cpp b/wpilibcIntegrationTests/src/main/native/cpp/MotorInvertingTest.cpp index 1e73d972be..ed1821bbee 100644 --- a/wpilibcIntegrationTests/src/main/native/cpp/MotorInvertingTest.cpp +++ b/wpilibcIntegrationTests/src/main/native/cpp/MotorInvertingTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2014-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2014-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. */ @@ -152,6 +152,5 @@ TEST_P(MotorInvertingTest, InvertingSwitchingNegToPos) { Reset(); } -INSTANTIATE_TEST_CASE_P(Test, MotorInvertingTest, - testing::Values(TEST_VICTOR, TEST_JAGUAR, - TEST_TALON), ); +INSTANTIATE_TEST_SUITE_P(Test, MotorInvertingTest, + testing::Values(TEST_VICTOR, TEST_JAGUAR, TEST_TALON)); diff --git a/wpiutil/CMakeLists.txt b/wpiutil/CMakeLists.txt index de66a96713..720940c81a 100644 --- a/wpiutil/CMakeLists.txt +++ b/wpiutil/CMakeLists.txt @@ -80,7 +80,7 @@ set_property(TARGET wpiutil PROPERTY FOLDER "libraries") if (NOT MSVC) target_compile_options(wpiutil PUBLIC -std=c++14 -Wall -pedantic -Wextra -Wno-unused-parameter) else() - target_compile_options(wpiutil PUBLIC -DNOMINMAX) + target_compile_options(wpiutil PUBLIC /wd4244 /wd4267 /wd4146 /WX /permissive- /std:c++17) target_compile_options(wpiutil PRIVATE -D_CRT_SECURE_NO_WARNINGS) endif() diff --git a/wpiutil/src/main/native/cpp/TCPAcceptor.cpp b/wpiutil/src/main/native/cpp/TCPAcceptor.cpp index 0abf8623f6..90d9496837 100644 --- a/wpiutil/src/main/native/cpp/TCPAcceptor.cpp +++ b/wpiutil/src/main/native/cpp/TCPAcceptor.cpp @@ -27,6 +27,7 @@ #include #ifdef _WIN32 +#define _WINSOCK_DEPRECATED_NO_WARNINGS #include #include #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 diff --git a/wpiutil/src/main/native/cpp/WebSocket.cpp b/wpiutil/src/main/native/cpp/WebSocket.cpp index a38be203fd..dca081bec6 100644 --- a/wpiutil/src/main/native/cpp/WebSocket.cpp +++ b/wpiutil/src/main/native/cpp/WebSocket.cpp @@ -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; diff --git a/wpiutil/src/main/native/cpp/http_parser.cpp b/wpiutil/src/main/native/cpp/http_parser.cpp index 090021914c..fb56010d8e 100644 --- a/wpiutil/src/main/native/cpp/http_parser.cpp +++ b/wpiutil/src/main/native/cpp/http_parser.cpp @@ -25,6 +25,10 @@ #include #include +#ifdef _WIN32 +#pragma warning(disable : 4018 26451) +#endif + #ifndef ULLONG_MAX # define ULLONG_MAX ((uint64_t) -1) /* 2^64-1 */ #endif diff --git a/wpiutil/src/main/native/cpp/json.cpp b/wpiutil/src/main/native/cpp/json.cpp index 9becfdd63f..ba9cd8ef7a 100644 --- a/wpiutil/src/main/native/cpp/json.cpp +++ b/wpiutil/src/main/native/cpp/json.cpp @@ -142,24 +142,24 @@ void json::json_value::destroy(value_t t) noexcept case value_t::object: { std::allocator alloc; - alloc.destroy(object); - alloc.deallocate(object, 1); + std::allocator_traits::destroy(alloc, object); + std::allocator_traits::deallocate(alloc, object, 1); break; } case value_t::array: { std::allocator alloc; - alloc.destroy(array); - alloc.deallocate(array, 1); + std::allocator_traits::destroy(alloc, array); + std::allocator_traits::deallocate(alloc, array, 1); break; } case value_t::string: { std::allocator alloc; - alloc.destroy(string); - alloc.deallocate(string, 1); + std::allocator_traits::destroy(alloc, string); + std::allocator_traits::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::max_size() - return std::allocator().max_size(); + // delegate call to std::allocator::max_size() + return std::allocator_traits::max_size(*m_value.object); } default: diff --git a/wpiutil/src/main/native/cpp/llvm/Windows/Path.inc b/wpiutil/src/main/native/cpp/llvm/Windows/Path.inc index 7fcba15ecd..e9b5280f06 100644 --- a/wpiutil/src/main/native/cpp/llvm/Windows/Path.inc +++ b/wpiutil/src/main/native/cpp/llvm/Windows/Path.inc @@ -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 diff --git a/wpiutil/src/main/native/cpp/llvm/raw_ostream.cpp b/wpiutil/src/main/native/cpp/llvm/raw_ostream.cpp index a874b3a5c9..9f2942c56e 100644 --- a/wpiutil/src/main/native/cpp/llvm/raw_ostream.cpp +++ b/wpiutil/src/main/native/cpp/llvm/raw_ostream.cpp @@ -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" diff --git a/wpiutil/src/main/native/cpp/raw_istream.cpp b/wpiutil/src/main/native/cpp/raw_istream.cpp index bdfb2bb0ad..f63c217bbb 100644 --- a/wpiutil/src/main/native/cpp/raw_istream.cpp +++ b/wpiutil/src/main/native/cpp/raw_istream.cpp @@ -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 diff --git a/wpiutil/src/main/native/cpp/raw_uv_ostream.cpp b/wpiutil/src/main/native/cpp/raw_uv_ostream.cpp index 317de41be0..8fc103d25d 100644 --- a/wpiutil/src/main/native/cpp/raw_uv_ostream.cpp +++ b/wpiutil/src/main/native/cpp/raw_uv_ostream.cpp @@ -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; diff --git a/wpiutil/src/main/native/include/wpi/Compiler.h b/wpiutil/src/main/native/include/wpi/Compiler.h index 4a1513ec02..81b2fae0b0 100644 --- a/wpiutil/src/main/native/include/wpi/Compiler.h +++ b/wpiutil/src/main/native/include/wpi/Compiler.h @@ -117,6 +117,11 @@ #ifndef LLVM_NODISCARD #if __cplusplus > 201402L && __has_cpp_attribute(nodiscard) #define LLVM_NODISCARD [[nodiscard]] +// Detect MSVC directly, since __cplusplus still defaults to old version +#elif _MSVC_LANG >= 201703L +#define LLVM_NODISCARD [[nodiscard]] +#elif _MSC_VER +#define LLVM_NODISCARD #elif !__cplusplus // Workaround for llvm.org/PR23435, since clang 3.6 and below emit a spurious // error when __has_cpp_attribute is given a scoped attribute in C mode. @@ -236,6 +241,11 @@ #ifndef LLVM_FALLTHROUGH #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough) #define LLVM_FALLTHROUGH [[fallthrough]] +// Detect MSVC directly, since __cplusplus still defaults to old version +#elif _MSVC_LANG >= 201703L +#define LLVM_FALLTHROUGH [[fallthrough]] +#elif _MSC_VER +#define LLVM_FALLTHROUGH #elif __has_cpp_attribute(gnu::fallthrough) #define LLVM_FALLTHROUGH [[gnu::fallthrough]] #elif !__cplusplus diff --git a/wpiutil/src/main/native/include/wpi/DenseMap.h b/wpiutil/src/main/native/include/wpi/DenseMap.h index 5efc8cbf7f..12bb71260a 100644 --- a/wpiutil/src/main/native/include/wpi/DenseMap.h +++ b/wpiutil/src/main/native/include/wpi/DenseMap.h @@ -352,7 +352,7 @@ protected: return 0; // +1 is required because of the strict equality. // For example if NumEntries is 48, we need to return 401. - return NextPowerOf2(NumEntries * 4 / 3 + 1); + return static_cast(NextPowerOf2(NumEntries * 4 / 3 + 1)); } void moveFromOldBuckets(BucketT *OldBucketsBegin, BucketT *OldBucketsEnd) { @@ -777,7 +777,7 @@ public: // Reduce the number of buckets. unsigned NewNumBuckets = 0; if (OldNumEntries) - NewNumBuckets = std::max(64, 1 << (Log2_32_Ceil(OldNumEntries) + 1)); + NewNumBuckets = (std::max)(64, 1 << (Log2_32_Ceil(OldNumEntries) + 1)); if (NewNumBuckets == NumBuckets) { this->BaseT::initEmpty(); return; diff --git a/wpiutil/src/main/native/include/wpi/DenseMapInfo.h b/wpiutil/src/main/native/include/wpi/DenseMapInfo.h index 6bc713a3a9..81ccdc710b 100644 --- a/wpiutil/src/main/native/include/wpi/DenseMapInfo.h +++ b/wpiutil/src/main/native/include/wpi/DenseMapInfo.h @@ -265,7 +265,7 @@ template struct DenseMapInfo> { template <> struct DenseMapInfo { static inline hash_code getEmptyKey() { return hash_code(-1); } static inline hash_code getTombstoneKey() { return hash_code(-2); } - static unsigned getHashValue(hash_code val) { return val; } + static unsigned getHashValue(hash_code val) { return static_cast(val); } static bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; } }; diff --git a/wpiutil/src/main/native/include/wpi/Error.h b/wpiutil/src/main/native/include/wpi/Error.h index 3ce87206cc..7dd820709d 100644 --- a/wpiutil/src/main/native/include/wpi/Error.h +++ b/wpiutil/src/main/native/include/wpi/Error.h @@ -183,7 +183,7 @@ public: /// Move-construct an error value. The newly constructed error is considered /// unchecked, even if the source error had been checked. The original error /// becomes a checked Success value, regardless of its original state. - Error(Error &&Other) { + Error(Error &&Other) noexcept { setChecked(true); *this = std::move(Other); } @@ -202,7 +202,7 @@ public: /// you cannot overwrite an unhandled error. The current error is then /// considered unchecked. The source error becomes a checked success value, /// regardless of its original state. - Error &operator=(Error &&Other) { + Error &operator=(Error &&Other) noexcept { // Don't allow overwriting of unchecked values. assertIsChecked(); setPtr(Other.getPtr()); diff --git a/wpiutil/src/main/native/include/wpi/Format.h b/wpiutil/src/main/native/include/wpi/Format.h index 34dd8d88e4..0a97ab03ca 100644 --- a/wpiutil/src/main/native/include/wpi/Format.h +++ b/wpiutil/src/main/native/include/wpi/Format.h @@ -94,7 +94,7 @@ class format_object final : public format_object_base { int snprint_tuple(char *Buffer, unsigned BufferSize, index_sequence) const { #ifdef _MSC_VER - return _snprintf(Buffer, BufferSize, Fmt, std::get(Vals)...); + return _snprintf_s(Buffer, BufferSize, BufferSize, Fmt, std::get(Vals)...); #else #ifdef __GNUC__ #pragma GCC diagnostic push diff --git a/wpiutil/src/main/native/include/wpi/Hashing.h b/wpiutil/src/main/native/include/wpi/Hashing.h index 157b2b9a4c..d59d695f65 100644 --- a/wpiutil/src/main/native/include/wpi/Hashing.h +++ b/wpiutil/src/main/native/include/wpi/Hashing.h @@ -55,6 +55,11 @@ #include #include +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 26495) +#endif + namespace wpi { /// An opaque object representing a hash code. @@ -192,7 +197,7 @@ inline uint64_t hash_1to3_bytes(const char *s, size_t len, uint64_t seed) { uint8_t b = s[len >> 1]; uint8_t c = s[len - 1]; uint32_t y = static_cast(a) + (static_cast(b) << 8); - uint32_t z = len + (static_cast(c) << 2); + uint32_t z = static_cast(len + (static_cast(c) << 2)); return shift_mix(y * k2 ^ z * k3 ^ seed) * k2; } @@ -568,7 +573,7 @@ public: // Check whether the entire set of values fit in the buffer. If so, we'll // use the optimized short hashing routine and skip state entirely. if (length == 0) - return hash_short(buffer, buffer_ptr - buffer, seed); + return static_cast(hash_short(buffer, buffer_ptr - buffer, seed)); // Mix the final buffer, rotating it if we did a partial fill in order to // simulate doing a mix of the last 64-bytes. That is how the algorithm @@ -580,7 +585,7 @@ public: state.mix(buffer); length += buffer_ptr - buffer; - return state.finalize(length); + return static_cast(state.finalize(length)); } }; @@ -619,7 +624,7 @@ inline hash_code hash_integer_value(uint64_t value) { const uint64_t seed = get_execution_seed(); const char *s = reinterpret_cast(&value); const uint64_t a = fetch32(s); - return hash_16_bytes(seed + (a << 3), fetch32(s + 4)); + return static_cast(hash_16_bytes(seed + (a << 3), fetch32(s + 4))); } } // namespace detail @@ -657,4 +662,8 @@ hash_code hash_value(const std::basic_string &arg) { } // namespace wpi +#ifdef _WIN32 +#pragma warning(pop) +#endif + #endif diff --git a/wpiutil/src/main/native/include/wpi/MathExtras.h b/wpiutil/src/main/native/include/wpi/MathExtras.h index 49f5e4e121..4dda4342c9 100644 --- a/wpiutil/src/main/native/include/wpi/MathExtras.h +++ b/wpiutil/src/main/native/include/wpi/MathExtras.h @@ -58,7 +58,7 @@ template struct TrailingZerosCounter { // Bisection method. std::size_t ZeroBits = 0; T Shift = std::numeric_limits::digits >> 1; - T Mask = std::numeric_limits::max() >> Shift; + T Mask = (std::numeric_limits::max)() >> Shift; while (Shift) { if ((Val & Mask) == 0) { Val >>= Shift; @@ -199,7 +199,7 @@ std::size_t countLeadingZeros(T Val, ZeroBehavior ZB = ZB_Width) { /// valid arguments. template T findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) { if (ZB == ZB_Max && Val == 0) - return std::numeric_limits::max(); + return (std::numeric_limits::max)(); return countTrailingZeros(Val, ZB_Undefined); } @@ -240,7 +240,7 @@ template T maskLeadingZeros(unsigned N) { /// valid arguments. template T findLastSet(T Val, ZeroBehavior ZB = ZB_Max) { if (ZB == ZB_Max && Val == 0) - return std::numeric_limits::max(); + return (std::numeric_limits::max)(); // Use ^ instead of - because both gcc and llvm can remove the associated ^ // in the __builtin_clz intrinsic on x86. @@ -370,6 +370,11 @@ inline uint64_t maxUIntN(uint64_t N) { return UINT64_MAX >> (64 - N); } +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4146) +#endif + /// Gets the minimum value for a N-bit signed integer. inline int64_t minIntN(int64_t N) { assert(N > 0 && N <= 64 && "integer width out of range"); @@ -377,6 +382,10 @@ inline int64_t minIntN(int64_t N) { return -(UINT64_C(1)<<(N-1)); } +#ifdef _WIN32 +#pragma warning(pop) +#endif + /// Gets the maximum value for a N-bit signed integer. inline int64_t maxIntN(int64_t N) { assert(N > 0 && N <= 64 && "integer width out of range"); @@ -519,26 +528,26 @@ inline double Log2(double Value) { /// (32 bit edition.) /// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2 inline unsigned Log2_32(uint32_t Value) { - return 31 - countLeadingZeros(Value); + return static_cast(31 - countLeadingZeros(Value)); } /// Return the floor log base 2 of the specified value, -1 if the value is zero. /// (64 bit edition.) inline unsigned Log2_64(uint64_t Value) { - return 63 - countLeadingZeros(Value); + return static_cast(63 - countLeadingZeros(Value)); } /// Return the ceil log base 2 of the specified value, 32 if the value is zero. /// (32 bit edition). /// Ex. Log2_32_Ceil(32) == 5, Log2_32_Ceil(1) == 0, Log2_32_Ceil(6) == 3 inline unsigned Log2_32_Ceil(uint32_t Value) { - return 32 - countLeadingZeros(Value - 1); + return static_cast(32 - countLeadingZeros(Value - 1)); } /// Return the ceil log base 2 of the specified value, 64 if the value is zero. /// (64 bit edition.) inline unsigned Log2_64_Ceil(uint64_t Value) { - return 64 - countLeadingZeros(Value - 1); + return static_cast(64 - countLeadingZeros(Value - 1)); } /// Return the greatest common divisor of the values using Euclid's algorithm. @@ -747,7 +756,7 @@ inline int64_t SignExtend64(uint64_t X, unsigned B) { template typename std::enable_if::value, T>::type AbsoluteDifference(T X, T Y) { - return std::max(X, Y) - std::min(X, Y); + return (std::max)(X, Y) - (std::min)(X, Y); } /// Add two unsigned integers, X and Y, of type T. Clamp the result to the @@ -762,7 +771,7 @@ SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) { T Z = X + Y; Overflowed = (Z < X || Z < Y); if (Overflowed) - return std::numeric_limits::max(); + return (std::numeric_limits::max)(); else return Z; } @@ -787,7 +796,7 @@ SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) { // Special case: if X or Y is 0, Log2_64 gives -1, and Log2Z // will necessarily be less than Log2Max as desired. int Log2Z = Log2_64(X) + Log2_64(Y); - const T Max = std::numeric_limits::max(); + const T Max = (std::numeric_limits::max)(); int Log2Max = Log2_64(Max); if (Log2Z < Log2Max) { return X * Y; diff --git a/wpiutil/src/main/native/include/wpi/MemAlloc.h b/wpiutil/src/main/native/include/wpi/MemAlloc.h index 56cb5df083..addccb5431 100644 --- a/wpiutil/src/main/native/include/wpi/MemAlloc.h +++ b/wpiutil/src/main/native/include/wpi/MemAlloc.h @@ -23,6 +23,14 @@ namespace wpi { +#ifdef _WIN32 +#pragma warning(push) +// Warning on NONNULL, report is not known to abort +#pragma warning(disable : 6387) +#pragma warning(disable : 28196) +#pragma warning(disable : 28183) +#endif + LLVM_ATTRIBUTE_RETURNS_NONNULL inline void *safe_malloc(size_t Sz) { void *Result = std::malloc(Sz); if (Result == nullptr) @@ -45,5 +53,9 @@ LLVM_ATTRIBUTE_RETURNS_NONNULL inline void *safe_realloc(void *Ptr, size_t Sz) { return Result; } +#ifdef _WIN32 +#pragma warning(pop) +#endif + } #endif diff --git a/wpiutil/src/main/native/include/wpi/Path.h b/wpiutil/src/main/native/include/wpi/Path.h index 26b19785d8..2a8e94c510 100644 --- a/wpiutil/src/main/native/include/wpi/Path.h +++ b/wpiutil/src/main/native/include/wpi/Path.h @@ -22,6 +22,12 @@ #include #include +#ifdef _WIN32 +// Disable iterator deprecation warning +#pragma warning(push) +#pragma warning(disable : 4996) +#endif + namespace wpi { namespace sys { namespace path { @@ -460,4 +466,8 @@ std::error_code widenPath(const Twine &Path8, SmallVectorImpl &Path16); } // end namespace sys } // end namespace wpi +#ifdef _WIN32 +#pragma warning(pop) +#endif + #endif diff --git a/wpiutil/src/main/native/include/wpi/STLExtras.h b/wpiutil/src/main/native/include/wpi/STLExtras.h index e32a8571df..a26a8e279b 100644 --- a/wpiutil/src/main/native/include/wpi/STLExtras.h +++ b/wpiutil/src/main/native/include/wpi/STLExtras.h @@ -1310,7 +1310,7 @@ template struct result_pair { ValueOfRange &value() { return *Iter; } private: - std::size_t Index = std::numeric_limits::max(); + std::size_t Index = (std::numeric_limits::max)(); IterOfRange Iter; }; @@ -1325,7 +1325,7 @@ class enumerator_iter public: explicit enumerator_iter(IterOfRange EndIter) - : Result(std::numeric_limits::max(), EndIter) {} + : Result((std::numeric_limits::max)(), EndIter) {} enumerator_iter(std::size_t Index, IterOfRange Iter) : Result(Index, Iter) {} @@ -1334,7 +1334,7 @@ public: const result_type &operator*() const { return Result; } enumerator_iter &operator++() { - assert(Result.Index != std::numeric_limits::max()); + assert(Result.Index != (std::numeric_limits::max)()); ++Result.Iter; ++Result.Index; return *this; diff --git a/wpiutil/src/main/native/include/wpi/SafeThread.h b/wpiutil/src/main/native/include/wpi/SafeThread.h index ec4e2e15af..a2de41426e 100644 --- a/wpiutil/src/main/native/include/wpi/SafeThread.h +++ b/wpiutil/src/main/native/include/wpi/SafeThread.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* 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. */ @@ -67,7 +67,7 @@ class SafeThreadOwnerBase { : SafeThreadOwnerBase() { swap(*this, other); } - SafeThreadOwnerBase& operator=(SafeThreadOwnerBase other) noexcept { + SafeThreadOwnerBase& operator=(SafeThreadOwnerBase&& other) noexcept { swap(*this, other); return *this; } diff --git a/wpiutil/src/main/native/include/wpi/SmallVector.h b/wpiutil/src/main/native/include/wpi/SmallVector.h index 93ab2b4457..430f85a5c5 100644 --- a/wpiutil/src/main/native/include/wpi/SmallVector.h +++ b/wpiutil/src/main/native/include/wpi/SmallVector.h @@ -50,7 +50,7 @@ protected: SmallVectorBase() = delete; SmallVectorBase(void *FirstEl, size_t Capacity) - : BeginX(FirstEl), Capacity(Capacity) {} + : BeginX(FirstEl), Capacity(static_cast(Capacity)) {} /// This is an implementation of the grow() method which only works /// on POD-like data types and is out of line to reduce code duplication. @@ -75,7 +75,7 @@ public: /// which will only be overwritten. void set_size(size_t Size) { assert(Size <= capacity()); - this->Size = Size; + this->Size = static_cast(Size); } }; @@ -252,7 +252,7 @@ void SmallVectorTemplateBase::grow(size_t MinSize) { // Always grow, even from zero. size_t NewCapacity = size_t(NextPowerOf2(this->capacity() + 2)); - NewCapacity = std::min(std::max(NewCapacity, MinSize), size_t(UINT32_MAX)); + NewCapacity = (std::min)((std::max)(NewCapacity, MinSize), size_t(UINT32_MAX)); T *NewElts = static_cast(wpi::safe_malloc(NewCapacity*sizeof(T))); // Move the elements over. @@ -266,7 +266,7 @@ void SmallVectorTemplateBase::grow(size_t MinSize) { free(this->begin()); this->BeginX = NewElts; - this->Capacity = NewCapacity; + this->Capacity = static_cast(NewCapacity); } diff --git a/wpiutil/src/main/native/include/wpi/StringExtras.h b/wpiutil/src/main/native/include/wpi/StringExtras.h index 16d0db071f..f420e2ae1d 100644 --- a/wpiutil/src/main/native/include/wpi/StringExtras.h +++ b/wpiutil/src/main/native/include/wpi/StringExtras.h @@ -60,14 +60,14 @@ inline unsigned hexDigitValue(char C) { if (C >= '0' && C <= '9') return C-'0'; if (C >= 'a' && C <= 'f') return C-'a'+10U; if (C >= 'A' && C <= 'F') return C-'A'+10U; - return -1U; + return (std::numeric_limits::max)(); } /// Checks if character \p C is one of the 10 decimal digits. inline bool isDigit(char C) { return C >= '0' && C <= '9'; } /// Checks if character \p C is a hexadecimal numeric character. -inline bool isHexDigit(char C) { return hexDigitValue(C) != -1U; } +inline bool isHexDigit(char C) { return hexDigitValue(C) != (std::numeric_limits::max)(); } /// Checks if character \p C is a valid letter as classified by "C" locale. inline bool isAlpha(char C) { @@ -151,7 +151,7 @@ inline std::string toHex(ArrayRef Input, bool LowerCase = false) { inline uint8_t hexFromNibbles(char MSB, char LSB) { unsigned U1 = hexDigitValue(MSB); unsigned U2 = hexDigitValue(LSB); - assert(U1 != -1U && U2 != -1U); + assert(U1 != (std::numeric_limits::max)() && U2 != (std::numeric_limits::max)()); return static_cast((U1 << 4) | U2); } diff --git a/wpiutil/src/main/native/include/wpi/StringMap.h b/wpiutil/src/main/native/include/wpi/StringMap.h index e6648ccd0b..dbfe8ede15 100644 --- a/wpiutil/src/main/native/include/wpi/StringMap.h +++ b/wpiutil/src/main/native/include/wpi/StringMap.h @@ -64,7 +64,7 @@ protected: protected: explicit StringMapImpl(unsigned itemSize) : ItemSize(itemSize) {} - StringMapImpl(StringMapImpl &&RHS) + StringMapImpl(StringMapImpl &&RHS) noexcept : TheTable(RHS.TheTable), NumBuckets(RHS.NumBuckets), NumItems(RHS.NumItems), NumTombstones(RHS.NumTombstones), ItemSize(RHS.ItemSize) { diff --git a/wpiutil/src/main/native/include/wpi/StringRef.h b/wpiutil/src/main/native/include/wpi/StringRef.h index c9e2e5d3c6..60fb789719 100644 --- a/wpiutil/src/main/native/include/wpi/StringRef.h +++ b/wpiutil/src/main/native/include/wpi/StringRef.h @@ -183,7 +183,7 @@ namespace wpi { LLVM_ATTRIBUTE_ALWAYS_INLINE int compare(StringRef RHS) const noexcept { // Check the prefix for a mismatch. - if (int Res = compareMemory(Data, RHS.Data, std::min(Length, RHS.Length))) + if (int Res = compareMemory(Data, RHS.Data, (std::min)(Length, RHS.Length))) return Res < 0 ? -1 : 1; // Otherwise the prefixes match, so we only need to check the lengths. @@ -274,7 +274,7 @@ namespace wpi { LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find(char C, size_t From = 0) const noexcept { - size_t FindBegin = std::min(From, Length); + size_t FindBegin = (std::min)(From, Length); if (FindBegin < Length) { // Avoid calling memchr with nullptr. // Just forward to memchr, which is faster than a hand-rolled loop. if (const void *P = ::memchr(Data + FindBegin, C, Length - FindBegin)) @@ -336,7 +336,7 @@ namespace wpi { /// found. LLVM_NODISCARD size_t rfind(char C, size_t From = npos) const noexcept { - From = std::min(From, Length); + From = (std::min)(From, Length); size_t i = From; while (i != 0) { --i; @@ -554,8 +554,8 @@ namespace wpi { LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N = npos) const noexcept { - Start = std::min(Start, Length); - return StringRef(Data + Start, std::min(N, Length - Start)); + Start = (std::min)(Start, Length); + return StringRef(Data + Start, (std::min)(N, Length - Start)); } /// Return a StringRef equal to 'this' but with only the first \p N @@ -666,8 +666,8 @@ namespace wpi { LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef slice(size_t Start, size_t End) const noexcept { - Start = std::min(Start, Length); - End = std::min(std::max(Start, End), Length); + Start = (std::min)(Start, Length); + End = (std::min)((std::max)(Start, End), Length); return StringRef(Data + Start, End - Start); } @@ -776,28 +776,28 @@ namespace wpi { /// the left removed. LLVM_NODISCARD StringRef ltrim(char Char) const noexcept { - return drop_front(std::min(Length, find_first_not_of(Char))); + return drop_front((std::min)(Length, find_first_not_of(Char))); } /// Return string with consecutive characters in \p Chars starting from /// the left removed. LLVM_NODISCARD StringRef ltrim(StringRef Chars = " \t\n\v\f\r") const noexcept { - return drop_front(std::min(Length, find_first_not_of(Chars))); + return drop_front((std::min)(Length, find_first_not_of(Chars))); } /// Return string with consecutive \p Char characters starting from the /// right removed. LLVM_NODISCARD StringRef rtrim(char Char) const noexcept { - return drop_back(size() - std::min(Length, find_last_not_of(Char) + 1)); + return drop_back(size() - (std::min)(Length, find_last_not_of(Char) + 1)); } /// Return string with consecutive characters in \p Chars starting from /// the right removed. LLVM_NODISCARD StringRef rtrim(StringRef Chars = " \t\n\v\f\r") const noexcept { - return drop_back(size() - std::min(Length, find_last_not_of(Chars) + 1)); + return drop_back(size() - (std::min)(Length, find_last_not_of(Chars) + 1)); } /// Return string with consecutive \p Char characters starting from the diff --git a/wpiutil/src/main/native/include/wpi/Twine.h b/wpiutil/src/main/native/include/wpi/Twine.h index b227a42cdc..a5b7e973e0 100644 --- a/wpiutil/src/main/native/include/wpi/Twine.h +++ b/wpiutil/src/main/native/include/wpi/Twine.h @@ -17,6 +17,11 @@ #include #include +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 26495) +#endif + namespace wpi { class raw_ostream; @@ -531,4 +536,8 @@ namespace wpi { } // end namespace wpi +#ifdef _WIN32 +#pragma warning(pop) +#endif + #endif // LLVM_ADT_TWINE_H diff --git a/wpiutil/src/main/native/include/wpi/WebSocket.h b/wpiutil/src/main/native/include/wpi/WebSocket.h index 418c134292..b3c3cd50b9 100644 --- a/wpiutil/src/main/native/include/wpi/WebSocket.h +++ b/wpiutil/src/main/native/include/wpi/WebSocket.h @@ -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. */ @@ -75,7 +75,7 @@ class WebSocket : public std::enable_shared_from_this { * Client connection options. */ struct ClientOptions { - ClientOptions() : handshakeTimeout{uv::Timer::Time::max()} {} + ClientOptions() : handshakeTimeout{(uv::Timer::Time::max)()} {} /** Timeout for the handshake request. */ uv::Timer::Time handshakeTimeout; diff --git a/wpiutil/src/main/native/include/wpi/json.h b/wpiutil/src/main/native/include/wpi/json.h index a3aa7762a5..1a8146ad2b 100644 --- a/wpiutil/src/main/native/include/wpi/json.h +++ b/wpiutil/src/main/native/include/wpi/json.h @@ -2962,12 +2962,14 @@ class json { std::allocator alloc; - auto deleter = [&](T * object) - { - alloc.deallocate(object, 1); - }; - std::unique_ptr object(alloc.allocate(1), deleter); - alloc.construct(object.get(), std::forward(args)...); + using AllocatorTraits = std::allocator_traits>; + + auto deleter = [&](T * object) + { + AllocatorTraits::deallocate(alloc, object, 1); + }; + std::unique_ptr object(AllocatorTraits::allocate(alloc, 1), deleter); + AllocatorTraits::construct(alloc, object.get(), std::forward(args)...); assert(object != nullptr); return object.release(); } @@ -5318,8 +5320,8 @@ class json if (is_string()) { std::allocator alloc; - alloc.destroy(m_value.string); - alloc.deallocate(m_value.string, 1); + std::allocator_traits::destroy(alloc, m_value.string); + std::allocator_traits::deallocate(alloc, m_value.string, 1); m_value.string = nullptr; } @@ -5422,8 +5424,8 @@ class json if (is_string()) { std::allocator alloc; - alloc.destroy(m_value.string); - alloc.deallocate(m_value.string, 1); + std::allocator_traits::destroy(alloc, m_value.string); + std::allocator_traits::deallocate(alloc, m_value.string, 1); m_value.string = nullptr; } @@ -8077,7 +8079,7 @@ namespace std @since version 1.0.0 */ template<> -inline void swap(wpi::json& j1, +inline void swap(wpi::json& j1, wpi::json& j2) noexcept( is_nothrow_move_constructible::value and is_nothrow_move_assignable::value diff --git a/wpiutil/src/main/native/include/wpi/optional.h b/wpiutil/src/main/native/include/wpi/optional.h index ed14b45961..1257172370 100644 --- a/wpiutil/src/main/native/include/wpi/optional.h +++ b/wpiutil/src/main/native/include/wpi/optional.h @@ -10,6 +10,10 @@ # ifndef WPIUTIL_WPI_OPTIONAL_H # define WPIUTIL_WPI_OPTIONAL_H +#ifdef _WIN32 +#define _SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING +#endif + # include # include # include @@ -77,7 +81,7 @@ struct has_overloaded_addressof { template constexpr static bool has_overload(...) { return false; } - + template ().operator&()) > constexpr static bool has_overload(bool) { return true; } @@ -97,15 +101,15 @@ T* static_addressof(T& ref) } -// the call to convert(b) has return type A and converts b to type A iff b decltype(b) is implicitly convertible to A +// the call to convert(b) has return type A and converts b to type A iff b decltype(b) is implicitly convertible to A template constexpr U convert(U v) { return v; } - + namespace swap_ns { using std::swap; - + template void adl_swap(T& t, T& u) noexcept(noexcept(swap(t, u))) { @@ -230,12 +234,12 @@ class optional : private OptionalBase { static_assert( !std::is_same::type, nullopt_t>::value, "bad T" ); static_assert( !std::is_same::type, in_place_t>::value, "bad T" ); - + constexpr bool initialized() const noexcept { return OptionalBase::init_; } typename std::remove_const::type* dataptr() { return std::addressof(OptionalBase::storage_.value_); } constexpr const T* dataptr() const { return detail_::static_addressof(OptionalBase::storage_.value_); } - + constexpr const T& contained_val() const& { return OptionalBase::storage_.value_; } # if OPTIONAL_HAS_MOVE_ACCESSORS == 1 constexpr T&& contained_val() && { return std::move(OptionalBase::storage_.value_); } @@ -249,7 +253,7 @@ class optional : private OptionalBase if (initialized()) dataptr()->T::~T(); OptionalBase::init_ = false; } - + template void initialize(Args&&... args) noexcept(noexcept(T(std::forward(args)...))) { @@ -312,7 +316,7 @@ public: clear(); return *this; } - + optional& operator=(const optional& rhs) { if (initialized() == true && rhs.initialized() == false) clear(); @@ -320,7 +324,7 @@ public: else if (initialized() == true && rhs.initialized() == true) contained_val() = *rhs; return *this; } - + optional& operator=(optional&& rhs) noexcept(std::is_nothrow_move_assignable::value && std::is_nothrow_move_constructible::value) { @@ -342,22 +346,22 @@ public: else { initialize(std::forward(v)); } return *this; } - - + + template void emplace(Args&&... args) { clear(); initialize(std::forward(args)...); } - + template void emplace(std::initializer_list il, Args&&... args) { clear(); initialize(il, std::forward(args)...); } - + // 20.5.4.4, Swap void swap(optional& rhs) noexcept(std::is_nothrow_move_constructible::value && noexcept(detail_::swap_ns::adl_swap(std::declval(), std::declval()))) @@ -368,30 +372,30 @@ public: } // 20.5.4.5, Observers - + explicit constexpr operator bool() const noexcept { return initialized(); } constexpr bool has_value() const noexcept { return initialized(); } - + constexpr T const* operator ->() const { return TR2_OPTIONAL_ASSERTED_EXPRESSION(initialized(), dataptr()); } - + # if OPTIONAL_HAS_MOVE_ACCESSORS == 1 constexpr T* operator ->() { assert (initialized()); return dataptr(); } - + constexpr T const& operator *() const& { return TR2_OPTIONAL_ASSERTED_EXPRESSION(initialized(), contained_val()); } - + constexpr T& operator *() & { assert (initialized()); return contained_val(); } - + constexpr T&& operator *() && { assert (initialized()); return constexpr_move(contained_val()); @@ -400,48 +404,48 @@ public: constexpr T const& value() const& { return initialized() ? contained_val() : (throw bad_optional_access("bad optional access"), contained_val()); } - + constexpr T& value() & { return initialized() ? contained_val() : (throw bad_optional_access("bad optional access"), contained_val()); } - + constexpr T&& value() && { if (!initialized()) throw bad_optional_access("bad optional access"); return std::move(contained_val()); } - + # else T* operator ->() { assert (initialized()); return dataptr(); } - + constexpr T const& operator *() const { return TR2_OPTIONAL_ASSERTED_EXPRESSION(initialized(), contained_val()); } - + T& operator *() { assert (initialized()); return contained_val(); } - + constexpr T const& value() const { return initialized() ? contained_val() : (throw bad_optional_access("bad optional access"), contained_val()); } - + T& value() { return initialized() ? contained_val() : (throw bad_optional_access("bad optional access"), contained_val()); } - + # endif - + template constexpr T value_or(V&& v) const& { return *this ? **this : detail_::convert(constexpr_forward(v)); } - + # if OPTIONAL_HAS_MOVE_ACCESSORS == 1 template @@ -451,15 +455,15 @@ public: } # else - + template T value_or(V&& v) && { return *this ? constexpr_move(const_cast&>(*this).contained_val()) : detail_::convert(constexpr_forward(v)); } - + # endif - + // 20.6.3.6, modifiers void reset() noexcept { clear(); } }; @@ -471,42 +475,42 @@ class optional static_assert( !std::is_same::value, "bad T" ); static_assert( !std::is_same::value, "bad T" ); T* ref; - + public: // 20.5.5.1, construction/destruction constexpr optional() noexcept : ref(nullptr) {} - + constexpr optional(nullopt_t) noexcept : ref(nullptr) {} - + constexpr optional(T& v) noexcept : ref(detail_::static_addressof(v)) {} - + optional(T&&) = delete; - + constexpr optional(const optional& rhs) noexcept : ref(rhs.ref) {} - + explicit constexpr optional(in_place_t, T& v) noexcept : ref(detail_::static_addressof(v)) {} - + explicit optional(in_place_t, T&&) = delete; - + ~optional() = default; - + // 20.5.5.2, mutation optional& operator=(nullopt_t) noexcept { ref = nullptr; return *this; } - + // optional& operator=(const optional& rhs) noexcept { // ref = rhs.ref; // return *this; // } - + // optional& operator=(optional&& rhs) noexcept { // ref = rhs.ref; // return *this; // } - + template auto operator=(U&& rhs) noexcept -> typename std::enable_if @@ -518,7 +522,7 @@ public: ref = rhs.ref; return *this; } - + template auto operator=(U&& rhs) noexcept -> typename std::enable_if @@ -527,40 +531,40 @@ public: optional& >::type = delete; - + void emplace(T& v) noexcept { ref = detail_::static_addressof(v); } - + void emplace(T&&) = delete; - - + + void swap(optional& rhs) noexcept { std::swap(ref, rhs.ref); } - + // 20.5.5.3, observers constexpr T* operator->() const { return TR2_OPTIONAL_ASSERTED_EXPRESSION(ref, ref); } - + constexpr T& operator*() const { return TR2_OPTIONAL_ASSERTED_EXPRESSION(ref, *ref); } - + constexpr T& value() const { return ref ? *ref : (throw bad_optional_access("bad optional access"), *ref); } - + explicit constexpr operator bool() const noexcept { return ref != nullptr; } - + constexpr bool has_value() const noexcept { return ref != nullptr; } - + template constexpr typename std::decay::type value_or(V&& v) const { @@ -889,18 +893,18 @@ namespace std { typedef typename hash::result_type result_type; typedef wpi::optional argument_type; - + constexpr result_type operator()(argument_type const& arg) const { return arg ? std::hash{}(*arg) : result_type{}; } }; - + template struct hash> { typedef typename hash::result_type result_type; typedef wpi::optional argument_type; - + constexpr result_type operator()(argument_type const& arg) const { return arg ? std::hash{}(*arg) : result_type{}; } diff --git a/wpiutil/src/main/native/include/wpi/raw_istream.h b/wpiutil/src/main/native/include/wpi/raw_istream.h index 1e6faf9871..7fbbe0babe 100644 --- a/wpiutil/src/main/native/include/wpi/raw_istream.h +++ b/wpiutil/src/main/native/include/wpi/raw_istream.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* 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. */ @@ -49,7 +49,7 @@ class raw_istream { } size_t readsome(void* data, size_t len) { - size_t readlen = std::min(in_avail(), len); + size_t readlen = (std::min)(in_avail(), len); if (readlen == 0) return 0; read_impl(data, readlen); return m_read_count; diff --git a/wpiutil/src/main/native/include/wpi/uv/Buffer.h b/wpiutil/src/main/native/include/wpi/uv/Buffer.h index ceacb7c989..51acd76bb6 100644 --- a/wpiutil/src/main/native/include/wpi/uv/Buffer.h +++ b/wpiutil/src/main/native/include/wpi/uv/Buffer.h @@ -40,11 +40,11 @@ class Buffer : public uv_buf_t { : Buffer{reinterpret_cast(arr.data()), arr.size()} {} Buffer(char* base_, size_t len_) { base = base_; - len = len_; + len = static_cast(len_); } Buffer(const char* base_, size_t len_) { base = const_cast(base_); - len = len_; + len = static_cast(len_); } ArrayRef data() const { return ArrayRef{base, len}; } diff --git a/wpiutil/src/main/native/include/wpi/uv/Tcp.h b/wpiutil/src/main/native/include/wpi/uv/Tcp.h index 067c0fdc09..56c2b8ffa7 100644 --- a/wpiutil/src/main/native/include/wpi/uv/Tcp.h +++ b/wpiutil/src/main/native/include/wpi/uv/Tcp.h @@ -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. */ @@ -130,7 +130,8 @@ class Tcp final : public NetworkStreamImpl { * @return True in case of success, false otherwise. */ bool SetKeepAlive(bool enable, Time time = Time{0}) { - return uv_tcp_keepalive(GetRaw(), enable, time.count()) == 0; + return uv_tcp_keepalive(GetRaw(), enable, + static_cast(time.count())) == 0; } /** diff --git a/wpiutil/src/main/native/include/wpi/uv/Udp.h b/wpiutil/src/main/native/include/wpi/uv/Udp.h index 7ceb0bbb92..f27ab5fa43 100644 --- a/wpiutil/src/main/native/include/wpi/uv/Udp.h +++ b/wpiutil/src/main/native/include/wpi/uv/Udp.h @@ -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. */ @@ -244,7 +244,8 @@ class Udp final : public HandleImpl { * @return Number of bytes sent. */ int TrySend(const sockaddr& addr, ArrayRef bufs) { - int val = uv_udp_try_send(GetRaw(), bufs.data(), bufs.size(), &addr); + int val = uv_udp_try_send(GetRaw(), bufs.data(), + static_cast(bufs.size()), &addr); if (val < 0) { this->ReportError(val); return 0; diff --git a/wpiutil/src/main/native/libuv/include/uv/win.h b/wpiutil/src/main/native/libuv/include/uv/win.h index 87f1e781ce..a909f69ef9 100644 --- a/wpiutil/src/main/native/libuv/include/uv/win.h +++ b/wpiutil/src/main/native/libuv/include/uv/win.h @@ -181,11 +181,16 @@ typedef int (WSAAPI* LPFN_WSARECVFROM) LPWSAOVERLAPPED overlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); +#pragma warning(push) +#pragma warning(disable : 28251) + #ifndef _NTDEF_ typedef LONG NTSTATUS; typedef NTSTATUS *PNTSTATUS; #endif +#pragma warning(pop) + #ifndef RTL_CONDITION_VARIABLE_INIT typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE; #endif diff --git a/wpiutil/src/main/native/libuv/src/fs-poll.cpp b/wpiutil/src/main/native/libuv/src/fs-poll.cpp index 61cc737892..8e6da65102 100644 --- a/wpiutil/src/main/native/libuv/src/fs-poll.cpp +++ b/wpiutil/src/main/native/libuv/src/fs-poll.cpp @@ -26,6 +26,7 @@ #include #include + struct poll_ctx { uv_fs_poll_t* parent_handle; /* NULL if parent has been stopped or closed */ int busy_polling; diff --git a/wpiutil/src/main/native/libuv/src/inet.cpp b/wpiutil/src/main/native/libuv/src/inet.cpp index 79d62327e0..2d6fb6679f 100644 --- a/wpiutil/src/main/native/libuv/src/inet.cpp +++ b/wpiutil/src/main/native/libuv/src/inet.cpp @@ -27,6 +27,10 @@ #include "uv.h" #include "uv-common.h" +#ifdef _WIN32 +#pragma warning(disable : 6001) +#endif + #define UV__INET_ADDRSTRLEN 16 #define UV__INET6_ADDRSTRLEN 46 diff --git a/wpiutil/src/main/native/libuv/src/threadpool.cpp b/wpiutil/src/main/native/libuv/src/threadpool.cpp index 3b4b7cfdb2..1ff3f4432b 100644 --- a/wpiutil/src/main/native/libuv/src/threadpool.cpp +++ b/wpiutil/src/main/native/libuv/src/threadpool.cpp @@ -27,6 +27,10 @@ #include +#ifdef _WIN32 +#pragma warning(disable: 6001 6011) +#endif + #define MAX_THREADPOOL_SIZE 128 static uv_once_t once = UV_ONCE_INIT; diff --git a/wpiutil/src/main/native/libuv/src/win/dl.cpp b/wpiutil/src/main/native/libuv/src/win/dl.cpp index 97ac1c1ad1..82c681fa73 100644 --- a/wpiutil/src/main/native/libuv/src/win/dl.cpp +++ b/wpiutil/src/main/native/libuv/src/win/dl.cpp @@ -76,7 +76,7 @@ const char* uv_dlerror(const uv_lib_t* lib) { static void uv__format_fallback_error(uv_lib_t* lib, int errorno){ DWORD_PTR args[1] = { (DWORD_PTR) errorno }; - LPSTR fallback_error = "error: %1!d!"; + LPCSTR fallback_error = "error: %1!d!"; FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY | diff --git a/wpiutil/src/main/native/libuv/src/win/fs-event.cpp b/wpiutil/src/main/native/libuv/src/win/fs-event.cpp index 9ef90f3c60..95510d9504 100644 --- a/wpiutil/src/main/native/libuv/src/win/fs-event.cpp +++ b/wpiutil/src/main/native/libuv/src/win/fs-event.cpp @@ -19,6 +19,8 @@ * IN THE SOFTWARE. */ +#define _CRT_NONSTDC_NO_WARNINGS + #include #include #include diff --git a/wpiutil/src/main/native/libuv/src/win/fs.cpp b/wpiutil/src/main/native/libuv/src/win/fs.cpp index d7698a7e9b..fdcddd649f 100644 --- a/wpiutil/src/main/native/libuv/src/win/fs.cpp +++ b/wpiutil/src/main/native/libuv/src/win/fs.cpp @@ -19,6 +19,8 @@ * IN THE SOFTWARE. */ +#define _CRT_NONSTDC_NO_WARNINGS + #include #include #include diff --git a/wpiutil/src/main/native/libuv/src/win/pipe.cpp b/wpiutil/src/main/native/libuv/src/win/pipe.cpp index 80661d8353..5b453c1b9b 100644 --- a/wpiutil/src/main/native/libuv/src/win/pipe.cpp +++ b/wpiutil/src/main/native/libuv/src/win/pipe.cpp @@ -19,6 +19,8 @@ * IN THE SOFTWARE. */ +#define _CRT_NONSTDC_NO_WARNINGS + #include #include #include diff --git a/wpiutil/src/main/native/libuv/src/win/process-stdio.cpp b/wpiutil/src/main/native/libuv/src/win/process-stdio.cpp index 0ae9f0624a..3d10cd351b 100644 --- a/wpiutil/src/main/native/libuv/src/win/process-stdio.cpp +++ b/wpiutil/src/main/native/libuv/src/win/process-stdio.cpp @@ -116,6 +116,8 @@ static int uv__create_stdio_pipe_pair(uv_loop_t* loop, client_access |= GENERIC_WRITE | FILE_READ_ATTRIBUTES; } + BOOL overlap; + /* Create server pipe handle. */ err = uv_stdio_pipe_server(loop, server_pipe, @@ -130,7 +132,7 @@ static int uv__create_stdio_pipe_pair(uv_loop_t* loop, sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; - BOOL overlap = server_pipe->ipc || (flags & UV_OVERLAPPED_PIPE); + overlap = server_pipe->ipc || (flags & UV_OVERLAPPED_PIPE); child_pipe = CreateFileA(pipe_name, client_access, 0, diff --git a/wpiutil/src/main/native/libuv/src/win/process.cpp b/wpiutil/src/main/native/libuv/src/win/process.cpp index c47a3c4be5..a4d8b236d8 100644 --- a/wpiutil/src/main/native/libuv/src/win/process.cpp +++ b/wpiutil/src/main/native/libuv/src/win/process.cpp @@ -19,6 +19,8 @@ * IN THE SOFTWARE. */ +#define _CRT_NONSTDC_NO_WARNINGS + #include #include #include @@ -33,7 +35,6 @@ #include "handle-inl.h" #include "req-inl.h" - #define SIGKILL 9 diff --git a/wpiutil/src/main/native/libuv/src/win/tty.cpp b/wpiutil/src/main/native/libuv/src/win/tty.cpp index 4ac21b6310..173b02370d 100644 --- a/wpiutil/src/main/native/libuv/src/win/tty.cpp +++ b/wpiutil/src/main/native/libuv/src/win/tty.cpp @@ -19,6 +19,8 @@ * IN THE SOFTWARE. */ +#define _CRT_NONSTDC_NO_WARNINGS + #include #include #include diff --git a/wpiutil/src/test/native/cpp/Base64Test.cpp b/wpiutil/src/test/native/cpp/Base64Test.cpp index 99aecb965b..caa35aa238 100644 --- a/wpiutil/src/test/native/cpp/Base64Test.cpp +++ b/wpiutil/src/test/native/cpp/Base64Test.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* 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. */ @@ -85,8 +85,7 @@ static Base64TestParam sample[] = { "mQgc28gb24uLi4K"}, }; -INSTANTIATE_TEST_CASE_P(Base64Sample, Base64Test, - ::testing::ValuesIn(sample), ); +INSTANTIATE_TEST_SUITE_P(Base64Sample, Base64Test, ::testing::ValuesIn(sample)); static Base64TestParam standard[] = { {0, "", ""}, @@ -99,7 +98,7 @@ static Base64TestParam standard[] = { {2, "\xff\xef", "/+8="}, }; -INSTANTIATE_TEST_CASE_P(Base64Standard, Base64Test, - ::testing::ValuesIn(standard), ); +INSTANTIATE_TEST_SUITE_P(Base64Standard, Base64Test, + ::testing::ValuesIn(standard)); } // namespace wpi diff --git a/wpiutil/src/test/native/cpp/WebSocketClientTest.cpp b/wpiutil/src/test/native/cpp/WebSocketClientTest.cpp index 692e2a7dd9..afa123b664 100644 --- a/wpiutil/src/test/native/cpp/WebSocketClientTest.cpp +++ b/wpiutil/src/test/native/cpp/WebSocketClientTest.cpp @@ -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. */ @@ -222,8 +222,8 @@ class WebSocketClientDataTest : public WebSocketClientTest, std::shared_ptr ws; }; -INSTANTIATE_TEST_CASE_P(WebSocketClientDataTests, WebSocketClientDataTest, - ::testing::Values(0, 1, 125, 126, 65535, 65536), ); +INSTANTIATE_TEST_SUITE_P(WebSocketClientDataTests, WebSocketClientDataTest, + ::testing::Values(0, 1, 125, 126, 65535, 65536)); TEST_P(WebSocketClientDataTest, SendBinary) { int gotCallback = 0; diff --git a/wpiutil/src/test/native/cpp/WebSocketServerTest.cpp b/wpiutil/src/test/native/cpp/WebSocketServerTest.cpp index 7d723e3831..a93436e421 100644 --- a/wpiutil/src/test/native/cpp/WebSocketServerTest.cpp +++ b/wpiutil/src/test/native/cpp/WebSocketServerTest.cpp @@ -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. */ @@ -257,10 +257,10 @@ class WebSocketServerBadOpcodeTest : public WebSocketServerTest, public ::testing::WithParamInterface {}; -INSTANTIATE_TEST_CASE_P(WebSocketServerBadOpcodeTests, - WebSocketServerBadOpcodeTest, - ::testing::Values(3, 4, 5, 6, 7, 0xb, 0xc, 0xd, 0xe, - 0xf), ); +INSTANTIATE_TEST_SUITE_P(WebSocketServerBadOpcodeTests, + WebSocketServerBadOpcodeTest, + ::testing::Values(3, 4, 5, 6, 7, 0xb, 0xc, 0xd, 0xe, + 0xf)); TEST_P(WebSocketServerBadOpcodeTest, Receive) { int gotCallback = 0; @@ -289,9 +289,9 @@ class WebSocketServerControlFrameTest : public WebSocketServerTest, public ::testing::WithParamInterface {}; -INSTANTIATE_TEST_CASE_P(WebSocketServerControlFrameTests, - WebSocketServerControlFrameTest, - ::testing::Values(0x8, 0x9, 0xa), ); +INSTANTIATE_TEST_SUITE_P(WebSocketServerControlFrameTests, + WebSocketServerControlFrameTest, + ::testing::Values(0x8, 0x9, 0xa)); TEST_P(WebSocketServerControlFrameTest, ReceiveFragment) { int gotCallback = 0; @@ -532,8 +532,8 @@ TEST_F(WebSocketServerTest, ReceiveTooLargeFragmented) { class WebSocketServerDataTest : public WebSocketServerTest, public ::testing::WithParamInterface {}; -INSTANTIATE_TEST_CASE_P(WebSocketServerDataTests, WebSocketServerDataTest, - ::testing::Values(0, 1, 125, 126, 65535, 65536), ); +INSTANTIATE_TEST_SUITE_P(WebSocketServerDataTests, WebSocketServerDataTest, + ::testing::Values(0, 1, 125, 126, 65535, 65536)); TEST_P(WebSocketServerDataTest, SendText) { int gotCallback = 0; diff --git a/wpiutil/src/test/native/cpp/json/unit-cbor.cpp b/wpiutil/src/test/native/cpp/json/unit-cbor.cpp index 84e98eb202..2e37a17d04 100644 --- a/wpiutil/src/test/native/cpp/json/unit-cbor.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-cbor.cpp @@ -139,8 +139,8 @@ static const int64_t neg8_numbers[] = { -4294967297, }; -INSTANTIATE_TEST_CASE_P(CborSignedNeg8Tests, CborSignedNeg8Test, - ::testing::ValuesIn(neg8_numbers), ); +INSTANTIATE_TEST_SUITE_P(CborSignedNeg8Tests, CborSignedNeg8Test, + ::testing::ValuesIn(neg8_numbers)); // -4294967296..-65537 class CborSignedNeg4Test : public ::testing::TestWithParam {}; @@ -189,8 +189,8 @@ static const int64_t neg4_numbers[] = { -4294967296, }; -INSTANTIATE_TEST_CASE_P(CborSignedNeg4Tests, CborSignedNeg4Test, - ::testing::ValuesIn(neg4_numbers), ); +INSTANTIATE_TEST_SUITE_P(CborSignedNeg4Tests, CborSignedNeg4Test, + ::testing::ValuesIn(neg4_numbers)); // -65536..-257 TEST(CborSignedTest, Neg2) @@ -447,8 +447,8 @@ static const uint32_t pos4_numbers[] = { 1048576u, }; -INSTANTIATE_TEST_CASE_P(CborSignedPos4Tests, CborSignedPos4Test, - ::testing::ValuesIn(pos4_numbers), ); +INSTANTIATE_TEST_SUITE_P(CborSignedPos4Tests, CborSignedPos4Test, + ::testing::ValuesIn(pos4_numbers)); // 4294967296..4611686018427387903 class CborSignedPos8Test : public ::testing::TestWithParam {}; @@ -500,8 +500,8 @@ static const uint64_t pos8_numbers[] = { 4611686018427387903ul }; -INSTANTIATE_TEST_CASE_P(CborSignedPos8Tests, CborSignedPos8Test, - ::testing::ValuesIn(pos8_numbers), ); +INSTANTIATE_TEST_SUITE_P(CborSignedPos8Tests, CborSignedPos8Test, + ::testing::ValuesIn(pos8_numbers)); /* // -32768..-129 (int 16) @@ -670,8 +670,8 @@ TEST_P(CborUnsignedPos4Test, Case) EXPECT_EQ(json::from_cbor(result), j); } -INSTANTIATE_TEST_CASE_P(CborUnsignedPos4Tests, CborUnsignedPos4Test, - ::testing::ValuesIn(pos4_numbers), ); +INSTANTIATE_TEST_SUITE_P(CborUnsignedPos4Tests, CborUnsignedPos4Test, + ::testing::ValuesIn(pos4_numbers)); // 4294967296..4611686018427387903 (eight-byte uint64_t) class CborUnsignedPos8Test : public ::testing::TestWithParam {}; @@ -716,8 +716,8 @@ TEST_P(CborUnsignedPos8Test, Case) EXPECT_EQ(json::from_cbor(result), j); } -INSTANTIATE_TEST_CASE_P(CborUnsignedPos8Tests, CborUnsignedPos8Test, - ::testing::ValuesIn(pos8_numbers), ); +INSTANTIATE_TEST_SUITE_P(CborUnsignedPos8Tests, CborUnsignedPos8Test, + ::testing::ValuesIn(pos8_numbers)); // 3.1415925 TEST(CborFloatTest, Number) @@ -853,8 +853,8 @@ static size_t string3_lens[] = { 65535u }; -INSTANTIATE_TEST_CASE_P(CborString3Tests, CborString3Test, - ::testing::ValuesIn(string3_lens), ); +INSTANTIATE_TEST_SUITE_P(CborString3Tests, CborString3Test, + ::testing::ValuesIn(string3_lens)); // N = 65536..4294967295 class CborString5Test : public ::testing::TestWithParam {}; @@ -893,8 +893,8 @@ static size_t string5_lens[] = { 1048576u }; -INSTANTIATE_TEST_CASE_P(CborString5Tests, CborString5Test, - ::testing::ValuesIn(string5_lens), ); +INSTANTIATE_TEST_SUITE_P(CborString5Tests, CborString5Test, + ::testing::ValuesIn(string5_lens)); TEST(CborArrayTest, Empty) { @@ -948,7 +948,7 @@ TEST(CborArrayTest, UInt16) { json j(257, nullptr); std::vector expected(j.size() + 3, 0xf6); // all null - expected[0] = static_cast(0x99); // array 16 bit + expected[0] = static_cast(0x99); // array 16 bit expected[1] = 0x01; // size (0x0101), byte 0 expected[2] = 0x01; // size (0x0101), byte 1 const auto result = json::to_cbor(j); @@ -963,7 +963,7 @@ TEST(CborArrayTest, UInt32) { json j(65793, nullptr); std::vector expected(j.size() + 5, 0xf6); // all null - expected[0] = static_cast(0x9a); // array 32 bit + expected[0] = static_cast(0x9a); // array 32 bit expected[1] = 0x00; // size (0x00010101), byte 0 expected[2] = 0x01; // size (0x00010101), byte 1 expected[3] = 0x01; // size (0x00010101), byte 2 @@ -1236,8 +1236,8 @@ static const uint8_t unsupported_bytes_cases[] = { 0xf8, }; -INSTANTIATE_TEST_CASE_P(CborUnsupportedBytesTests, CborUnsupportedBytesTest, - ::testing::ValuesIn(unsupported_bytes_cases), ); +INSTANTIATE_TEST_SUITE_P(CborUnsupportedBytesTests, CborUnsupportedBytesTest, + ::testing::ValuesIn(unsupported_bytes_cases)); #if 0 // use this testcase outside [hide] to run it with Valgrind TEST(CborRoundtripTest, Sample) @@ -1327,7 +1327,7 @@ static const char* fuzz_test_cases[] = { "test/data/cbor_regression/test21", }; -INSTANTIATE_TEST_CASE_P(CborRegressionFuzzTests, CborRegressionFuzzTest, +INSTANTIATE_TEST_SUITE_P(CborRegressionFuzzTests, CborRegressionFuzzTest, ::testing::ValuesIn(fuzz_test_cases)); class CborRegressionFlynnTest : public ::testing::TestWithParam {}; @@ -1497,7 +1497,7 @@ static const char* flynn_test_cases[] = { "test/data/nst_json_testsuite/test_parsing/y_structure_whitespace_array.json", }; -INSTANTIATE_TEST_CASE_P(CborRegressionFlynnTests, CborRegressionFlynnTest, +INSTANTIATE_TEST_SUITE_P(CborRegressionFlynnTests, CborRegressionFlynnTest, ::testing::ValuesIn(flynn_test_cases)); #endif @@ -1644,16 +1644,16 @@ static const internal::CborRoundtripTestParam rfc7049_appendix_a_numbers[] = { {"-4.1", {0xfb,0xc0,0x10,0x66,0x66,0x66,0x66,0x66,0x66}, true}, }; -INSTANTIATE_TEST_CASE_P(CborRfc7049AppendixANumberTests, CborRoundtripTest, - ::testing::ValuesIn(rfc7049_appendix_a_numbers), ); +INSTANTIATE_TEST_SUITE_P(CborRfc7049AppendixANumberTests, CborRoundtripTest, + ::testing::ValuesIn(rfc7049_appendix_a_numbers)); static const internal::CborRoundtripTestParam rfc7049_appendix_a_simple_values[] = { {"false", {0xf4}, true}, {"true", {0xf5}, true}, }; -INSTANTIATE_TEST_CASE_P(CborRfc7049AppendixASimpleValueTests, CborRoundtripTest, - ::testing::ValuesIn(rfc7049_appendix_a_simple_values), ); +INSTANTIATE_TEST_SUITE_P(CborRfc7049AppendixASimpleValueTests, CborRoundtripTest, + ::testing::ValuesIn(rfc7049_appendix_a_simple_values)); static const internal::CborRoundtripTestParam rfc7049_appendix_a_strings[] = { {"\"\"", {0x60}, true}, @@ -1666,8 +1666,8 @@ static const internal::CborRoundtripTestParam rfc7049_appendix_a_strings[] = { {"\"streaming\"", {0x7f,0x65,0x73,0x74,0x72,0x65,0x61,0x64,0x6d,0x69,0x6e,0x67,0xff}, false}, }; -INSTANTIATE_TEST_CASE_P(CborRfc7049AppendixAStringTests, CborRoundtripTest, - ::testing::ValuesIn(rfc7049_appendix_a_strings), ); +INSTANTIATE_TEST_SUITE_P(CborRfc7049AppendixAStringTests, CborRoundtripTest, + ::testing::ValuesIn(rfc7049_appendix_a_strings)); static const internal::CborRoundtripTestParam rfc7049_appendix_a_arrays[] = { {"[]", {0x80}, true}, @@ -1683,8 +1683,8 @@ static const internal::CborRoundtripTestParam rfc7049_appendix_a_arrays[] = { {"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]", {0x9f,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x18,0x18,0x19,0xff}, false}, }; -INSTANTIATE_TEST_CASE_P(CborRfc7049AppendixAArrayTests, CborRoundtripTest, - ::testing::ValuesIn(rfc7049_appendix_a_arrays), ); +INSTANTIATE_TEST_SUITE_P(CborRfc7049AppendixAArrayTests, CborRoundtripTest, + ::testing::ValuesIn(rfc7049_appendix_a_arrays)); static const internal::CborRoundtripTestParam rfc7049_appendix_a_objects[] = { {"{}", {0xa0}, true}, @@ -1697,5 +1697,5 @@ static const internal::CborRoundtripTestParam rfc7049_appendix_a_objects[] = { {"{\"Fun\": true, \"Amt\": -2}", {0xbf,0x63,0x46,0x75,0x6e,0xf5,0x63,0x41,0x6d,0x74,0x21,0xff}, false}, }; -INSTANTIATE_TEST_CASE_P(CborRfc7049AppendixAObjectTests, CborRoundtripTest, - ::testing::ValuesIn(rfc7049_appendix_a_objects), ); +INSTANTIATE_TEST_SUITE_P(CborRfc7049AppendixAObjectTests, CborRoundtripTest, + ::testing::ValuesIn(rfc7049_appendix_a_objects)); diff --git a/wpiutil/src/test/native/cpp/json/unit-constructor1.cpp b/wpiutil/src/test/native/cpp/json/unit-constructor1.cpp index 71c46781f6..85b9b91e61 100644 --- a/wpiutil/src/test/native/cpp/json/unit-constructor1.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-constructor1.cpp @@ -67,8 +67,8 @@ static const json::value_t construct_type_cases[] = { json::value_t::number_float, }; -INSTANTIATE_TEST_CASE_P(JsonConstructTypeTests, JsonConstructTypeTest, - ::testing::ValuesIn(construct_type_cases), ); +INSTANTIATE_TEST_SUITE_P(JsonConstructTypeTests, JsonConstructTypeTest, + ::testing::ValuesIn(construct_type_cases)); TEST(JsonConstructNullTest, NoParameter) @@ -214,7 +214,7 @@ typedef ::testing::Types, std::forward_list, std::array, std::vector, std::deque> JsonConstructArrayTestTypes; -TYPED_TEST_CASE(JsonConstructArrayTest, JsonConstructArrayTestTypes); +TYPED_TEST_SUITE(JsonConstructArrayTest, JsonConstructArrayTestTypes, ); // clang warns on missing braces on the TypeParam initializer line below. // Suppress this warning. @@ -405,7 +405,7 @@ typedef ::testing::Types< #endif > JsonConstructIntegerTestTypes; -TYPED_TEST_CASE(JsonConstructIntegerTest, JsonConstructIntegerTestTypes); +TYPED_TEST_SUITE(JsonConstructIntegerTest, JsonConstructIntegerTestTypes, ); TYPED_TEST(JsonConstructIntegerTest, Implicit) { @@ -523,7 +523,7 @@ typedef ::testing::Types JsonConstructFloatTestTypes; -TYPED_TEST_CASE(JsonConstructFloatTest, JsonConstructFloatTestTypes); +TYPED_TEST_SUITE(JsonConstructFloatTest, JsonConstructFloatTestTypes, ); TYPED_TEST(JsonConstructFloatTest, Implicit) { diff --git a/wpiutil/src/test/native/cpp/json/unit-conversions.cpp b/wpiutil/src/test/native/cpp/json/unit-conversions.cpp index e4981f27f6..b60e5ac1a7 100644 --- a/wpiutil/src/test/native/cpp/json/unit-conversions.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-conversions.cpp @@ -62,7 +62,7 @@ typedef ::testing::Types< , std::unordered_map , std::unordered_multimap > JsonGetObjectTestTypes; -TYPED_TEST_CASE(JsonGetObjectTest, JsonGetObjectTestTypes); +TYPED_TEST_SUITE(JsonGetObjectTest, JsonGetObjectTestTypes, ); TYPED_TEST(JsonGetObjectTest, Explicit) { @@ -109,7 +109,7 @@ typedef ::testing::Types, /*std::forward_list,*/ std::vector, std::deque> JsonGetArrayTestTypes; -TYPED_TEST_CASE(JsonGetArrayTest, JsonGetArrayTestTypes); +TYPED_TEST_SUITE(JsonGetArrayTest, JsonGetArrayTestTypes, ); TYPED_TEST(JsonGetArrayTest, Explicit) { @@ -200,7 +200,7 @@ class JsonGetStringTest : public ::testing::Test { }; typedef ::testing::Types JsonGetStringTestTypes; -TYPED_TEST_CASE(JsonGetStringTest, JsonGetStringTestTypes); +TYPED_TEST_SUITE(JsonGetStringTest, JsonGetStringTestTypes, ); TYPED_TEST(JsonGetStringTest, Explicit) { @@ -244,7 +244,7 @@ class JsonGetBooleanTest : public ::testing::Test { }; typedef ::testing::Types JsonGetBooleanTestTypes; -TYPED_TEST_CASE(JsonGetBooleanTest, JsonGetBooleanTestTypes); +TYPED_TEST_SUITE(JsonGetBooleanTest, JsonGetBooleanTestTypes, ); TYPED_TEST(JsonGetBooleanTest, Explicit) { @@ -328,7 +328,7 @@ typedef ::testing::Types< #endif > JsonGetIntegerTestTypes; -TYPED_TEST_CASE(JsonGetIntegerTest, JsonGetIntegerTestTypes); +TYPED_TEST_SUITE(JsonGetIntegerTest, JsonGetIntegerTestTypes, ); TYPED_TEST(JsonGetIntegerTest, Explicit) { @@ -381,7 +381,7 @@ class JsonGetFloatTest : public ::testing::Test { typedef ::testing::Types JsonGetFloatTestTypes; -TYPED_TEST_CASE(JsonGetFloatTest, JsonGetFloatTestTypes); +TYPED_TEST_SUITE(JsonGetFloatTest, JsonGetFloatTestTypes, ); TYPED_TEST(JsonGetFloatTest, Explicit) { diff --git a/wpiutil/src/test/native/cpp/json/unit-deserialization.cpp b/wpiutil/src/test/native/cpp/json/unit-deserialization.cpp index 12ac280948..2505ef50ec 100644 --- a/wpiutil/src/test/native/cpp/json/unit-deserialization.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-deserialization.cpp @@ -133,6 +133,6 @@ static const char* error_cases[] = { "\"\x7F\xF4\x7F", }; -INSTANTIATE_TEST_CASE_P(JsonDeserializationErrorTests, +INSTANTIATE_TEST_SUITE_P(JsonDeserializationErrorTests, JsonDeserializationErrorTest, - ::testing::ValuesIn(error_cases), ); + ::testing::ValuesIn(error_cases)); diff --git a/wpiutil/src/test/native/cpp/json/unit-msgpack.cpp b/wpiutil/src/test/native/cpp/json/unit-msgpack.cpp index 0c03ee06f3..c0a237d398 100644 --- a/wpiutil/src/test/native/cpp/json/unit-msgpack.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-msgpack.cpp @@ -253,8 +253,8 @@ static const uint32_t pos4_numbers[] = { 4294967295u, }; -INSTANTIATE_TEST_CASE_P(MessagePackSignedPos4Tests, MessagePackSignedPos4Test, - ::testing::ValuesIn(pos4_numbers), ); +INSTANTIATE_TEST_SUITE_P(MessagePackSignedPos4Tests, MessagePackSignedPos4Test, + ::testing::ValuesIn(pos4_numbers)); // 4294967296..9223372036854775807 (int 64) class MessagePackSignedPos8Test : public ::testing::TestWithParam {}; @@ -306,8 +306,8 @@ static const uint64_t pos8_numbers[] = { 9223372036854775807lu, }; -INSTANTIATE_TEST_CASE_P(MessagePackSignedPos8Tests, MessagePackSignedPos8Test, - ::testing::ValuesIn(pos8_numbers), ); +INSTANTIATE_TEST_SUITE_P(MessagePackSignedPos8Tests, MessagePackSignedPos8Test, + ::testing::ValuesIn(pos8_numbers)); // -128..-33 (int 8) TEST(MessagePackSignedTest, Neg1) @@ -419,8 +419,8 @@ static const int32_t neg4_numbers[] = { -2147483648ll, }; -INSTANTIATE_TEST_CASE_P(MessagePackSignedNeg4Tests, MessagePackSignedNeg4Test, - ::testing::ValuesIn(neg4_numbers), ); +INSTANTIATE_TEST_SUITE_P(MessagePackSignedNeg4Tests, MessagePackSignedNeg4Test, + ::testing::ValuesIn(neg4_numbers)); // -9223372036854775808..-2147483649 (int 64) class MessagePackSignedNeg8Test : public ::testing::TestWithParam {}; @@ -470,8 +470,8 @@ static const int64_t neg8_numbers[] = { -2147483649ll, }; -INSTANTIATE_TEST_CASE_P(MessagePackSignedNeg8Tests, MessagePackSignedNeg8Test, - ::testing::ValuesIn(neg8_numbers), ); +INSTANTIATE_TEST_SUITE_P(MessagePackSignedNeg8Tests, MessagePackSignedNeg8Test, + ::testing::ValuesIn(neg8_numbers)); // 0..127 (positive fixnum) TEST(MessagePackUnsignedTest, Pos0) @@ -605,9 +605,9 @@ TEST_P(MessagePackUnsignedPos4Test, Case) EXPECT_EQ(json::from_msgpack(result), j); } -INSTANTIATE_TEST_CASE_P(MessagePackUnsignedPos4Tests, +INSTANTIATE_TEST_SUITE_P(MessagePackUnsignedPos4Tests, MessagePackUnsignedPos4Test, - ::testing::ValuesIn(pos4_numbers), ); + ::testing::ValuesIn(pos4_numbers)); // 4294967296..18446744073709551615 (uint 64) class MessagePackUnsignedPos8Test : public ::testing::TestWithParam {}; @@ -652,9 +652,9 @@ TEST_P(MessagePackUnsignedPos8Test, Case) EXPECT_EQ(json::from_msgpack(result), j); } -INSTANTIATE_TEST_CASE_P(MessagePackUnsignedPos8Tests, +INSTANTIATE_TEST_SUITE_P(MessagePackUnsignedPos8Tests, MessagePackUnsignedPos8Test, - ::testing::ValuesIn(pos8_numbers), ); + ::testing::ValuesIn(pos8_numbers)); // 3.1415925 TEST(MessagePackFloatTest, Number) @@ -786,8 +786,8 @@ static size_t string3_lens[] = { 65535u }; -INSTANTIATE_TEST_CASE_P(MessagePackString3Tests, MessagePackString3Test, - ::testing::ValuesIn(string3_lens), ); +INSTANTIATE_TEST_SUITE_P(MessagePackString3Tests, MessagePackString3Test, + ::testing::ValuesIn(string3_lens)); // N = 65536..4294967295 @@ -827,8 +827,8 @@ static size_t string5_lens[] = { 1048576u }; -INSTANTIATE_TEST_CASE_P(MessagePackString5Tests, MessagePackString5Test, - ::testing::ValuesIn(string5_lens), ); +INSTANTIATE_TEST_SUITE_P(MessagePackString5Tests, MessagePackString5Test, + ::testing::ValuesIn(string5_lens)); TEST(MessagePackArrayTest, Empty) { @@ -1264,6 +1264,6 @@ static const char* regression_test_cases[] = { "test/data/nst_json_testsuite/test_parsing/y_structure_whitespace_array.json", }; -INSTANTIATE_TEST_CASE_P(MessagePackRegressionTests, MessagePackRegressionTest, +INSTANTIATE_TEST_SUITE_P(MessagePackRegressionTests, MessagePackRegressionTest, ::testing::ValuesIn(regression_test_cases)); #endif