diff --git a/cmake/modules/CompileWarnings.cmake b/cmake/modules/CompileWarnings.cmake index b9d1ab8639..911787d2ef 100644 --- a/cmake/modules/CompileWarnings.cmake +++ b/cmake/modules/CompileWarnings.cmake @@ -1,7 +1,7 @@ macro(wpilib_target_warnings target) if(NOT MSVC) - target_compile_options(${target} PRIVATE -Wall -pedantic -Wextra -Werror -Wno-unused-parameter -Wno-error=deprecated-declarations ${WPILIB_TARGET_WARNINGS}) + target_compile_options(${target} PRIVATE -Wall -pedantic -Wextra -Werror -Wno-unused-parameter ${WPILIB_TARGET_WARNINGS}) else() - target_compile_options(${target} PRIVATE /wd4146 /wd4244 /wd4251 /wd4267 /wd4996 /WX ${WPILIB_TARGET_WARNINGS}) + target_compile_options(${target} PRIVATE /wd4146 /wd4244 /wd4251 /wd4267 /WX /D_CRT_SECURE_NO_WARNINGS ${WPILIB_TARGET_WARNINGS}) endif() endmacro() diff --git a/crossConnIntegrationTests/build.gradle b/crossConnIntegrationTests/build.gradle index 9320c4ec5c..1c55e1bb38 100644 --- a/crossConnIntegrationTests/build.gradle +++ b/crossConnIntegrationTests/build.gradle @@ -84,11 +84,6 @@ model { } } } - binary.tasks.withType(CppCompile) { - cppCompiler.args "-Wno-missing-field-initializers" - cppCompiler.args "-Wno-unused-variable" - cppCompiler.args "-Wno-error=deprecated-declarations" - } project(':hal').addHalDependency(binary, 'shared') project(':hal').addHalJniDependency(binary) lib project: ':wpinet', library: 'wpinet', linkage: 'shared' diff --git a/crossConnIntegrationTests/src/main/native/include/LifetimeWrappers.h b/crossConnIntegrationTests/src/main/native/include/LifetimeWrappers.h index 9f0eb15967..57312005d1 100644 --- a/crossConnIntegrationTests/src/main/native/include/LifetimeWrappers.h +++ b/crossConnIntegrationTests/src/main/native/include/LifetimeWrappers.h @@ -194,6 +194,7 @@ struct RelayHandle { do { \ ASSERT_EQ(status, HAL_USE_LAST_ERROR); \ const char* lastErrorMessageInMacro = HAL_GetLastError(&status); \ + static_cast(lastErrorMessageInMacro); \ ASSERT_EQ(status, x); \ } while (0) diff --git a/shared/java/javacommon.gradle b/shared/java/javacommon.gradle index 3dcad81a34..084af483aa 100644 --- a/shared/java/javacommon.gradle +++ b/shared/java/javacommon.gradle @@ -101,7 +101,9 @@ tasks.withType(JavaCompile).configureEach { '--release', '11', '-encoding', - 'UTF8' + 'UTF8', + "-Werror", + "-Xlint:deprecation,removal", ] } diff --git a/upstream_utils/libuv_patches/0001-Fix-missing-casts.patch b/upstream_utils/libuv_patches/0001-Fix-missing-casts.patch index 9596b81dc2..7560c1502b 100644 --- a/upstream_utils/libuv_patches/0001-Fix-missing-casts.patch +++ b/upstream_utils/libuv_patches/0001-Fix-missing-casts.patch @@ -1,7 +1,7 @@ -From 51c4e5107060a5decf24b642666eea1874ca8a04 Mon Sep 17 00:00:00 2001 +From 776fc617c56fdce3bc218e649a9bbfbdb6d4c8f9 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 26 Apr 2022 15:01:25 -0400 -Subject: [PATCH 1/7] Fix missing casts +Subject: [PATCH 1/8] Fix missing casts --- include/uv/unix.h | 2 +- diff --git a/upstream_utils/libuv_patches/0002-Fix-warnings.patch b/upstream_utils/libuv_patches/0002-Fix-warnings.patch index 13b325d5b1..4d6a74e3ce 100644 --- a/upstream_utils/libuv_patches/0002-Fix-warnings.patch +++ b/upstream_utils/libuv_patches/0002-Fix-warnings.patch @@ -1,7 +1,7 @@ -From f6b4cd53205fabd10ed0e2b275f3882aa0017061 Mon Sep 17 00:00:00 2001 +From 7727474439a3a3dc2b74c9c7ae4b1c36a11fdce2 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 26 Apr 2022 15:09:43 -0400 -Subject: [PATCH 2/7] Fix warnings +Subject: [PATCH 2/8] Fix warnings --- include/uv/win.h | 5 +++ diff --git a/upstream_utils/libuv_patches/0003-Preprocessor-cleanup.patch b/upstream_utils/libuv_patches/0003-Preprocessor-cleanup.patch index f913e5b82b..1969a56d7c 100644 --- a/upstream_utils/libuv_patches/0003-Preprocessor-cleanup.patch +++ b/upstream_utils/libuv_patches/0003-Preprocessor-cleanup.patch @@ -1,7 +1,7 @@ -From 20120ec8cb9310e243a71fe5bf9bee37eac7614b Mon Sep 17 00:00:00 2001 +From e9c7588e574cbf1fe99c0de7f9fcbb2910f03dd8 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 26 Apr 2022 15:19:14 -0400 -Subject: [PATCH 3/7] Preprocessor cleanup +Subject: [PATCH 3/8] Preprocessor cleanup --- include/uv.h | 18 +----------------- diff --git a/upstream_utils/libuv_patches/0004-Cleanup-problematic-language.patch b/upstream_utils/libuv_patches/0004-Cleanup-problematic-language.patch index 2f9c64da50..7b7bd6fee0 100644 --- a/upstream_utils/libuv_patches/0004-Cleanup-problematic-language.patch +++ b/upstream_utils/libuv_patches/0004-Cleanup-problematic-language.patch @@ -1,7 +1,7 @@ -From 644521f5d44152e0196cb630864d37ba79c8a39e Mon Sep 17 00:00:00 2001 +From 1a02de906b6182af54eeafff465d51364c0bbcc4 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 26 Apr 2022 15:24:47 -0400 -Subject: [PATCH 4/7] Cleanup problematic language +Subject: [PATCH 4/8] Cleanup problematic language --- src/unix/tty.c | 21 +++++++++++---------- diff --git a/upstream_utils/libuv_patches/0005-Use-roborio-time.patch b/upstream_utils/libuv_patches/0005-Use-roborio-time.patch index eaeaf26834..92ce8d5b06 100644 --- a/upstream_utils/libuv_patches/0005-Use-roborio-time.patch +++ b/upstream_utils/libuv_patches/0005-Use-roborio-time.patch @@ -1,7 +1,7 @@ -From 6ad2de945c69a58fbe092f549d5a6c7c02952cef Mon Sep 17 00:00:00 2001 +From ec156359c45abbd0a0547d442788477d8fb57fa0 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 26 Apr 2022 15:26:03 -0400 -Subject: [PATCH 5/7] Use roborio time +Subject: [PATCH 5/8] Use roborio time --- src/unix/linux-core.c | 8 ++++++++ diff --git a/upstream_utils/libuv_patches/0006-Style-comments-cleanup.patch b/upstream_utils/libuv_patches/0006-Style-comments-cleanup.patch index 69e18a7769..96c220f9f2 100644 --- a/upstream_utils/libuv_patches/0006-Style-comments-cleanup.patch +++ b/upstream_utils/libuv_patches/0006-Style-comments-cleanup.patch @@ -1,7 +1,7 @@ -From 6399ee267f6cc4cafda478b277c8888ee0b08632 Mon Sep 17 00:00:00 2001 +From 1131c424a6f54e3904eed0e2efb138ce4cce9c84 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 26 Apr 2022 15:28:52 -0400 -Subject: [PATCH 6/7] Style / comments cleanup +Subject: [PATCH 6/8] Style / comments cleanup --- src/fs-poll.c | 1 + diff --git a/upstream_utils/libuv_patches/0007-Squelch-GCC-12.1-warnings.patch b/upstream_utils/libuv_patches/0007-Squelch-GCC-12.1-warnings.patch index 9bccebb9c0..c8d49595c8 100644 --- a/upstream_utils/libuv_patches/0007-Squelch-GCC-12.1-warnings.patch +++ b/upstream_utils/libuv_patches/0007-Squelch-GCC-12.1-warnings.patch @@ -1,7 +1,7 @@ -From aa760b0bb41c8052f47f9d49eb100340c1c76634 Mon Sep 17 00:00:00 2001 +From 82d952b117b770bbefebd5308416ab767eb58234 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Tue, 17 May 2022 21:36:57 -0700 -Subject: [PATCH 7/7] Squelch GCC 12.1 warnings +Subject: [PATCH 7/8] Squelch GCC 12.1 warnings --- src/unix/stream.c | 9 +++++++++ diff --git a/upstream_utils/libuv_patches/0008-Fix-Win32-warning-suppression-pragma.patch b/upstream_utils/libuv_patches/0008-Fix-Win32-warning-suppression-pragma.patch new file mode 100644 index 0000000000..242a098e47 --- /dev/null +++ b/upstream_utils/libuv_patches/0008-Fix-Win32-warning-suppression-pragma.patch @@ -0,0 +1,25 @@ +From ff18404849ca7560c452f8a600982211de57aa5a Mon Sep 17 00:00:00 2001 +From: Tyler Veness +Date: Sat, 21 May 2022 22:58:06 -0700 +Subject: [PATCH 8/8] Fix Win32 warning suppression pragma + +--- + src/win/util.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/win/util.c b/src/win/util.c +index 7a5dd2ef..d9888aec 100644 +--- a/src/win/util.c ++++ b/src/win/util.c +@@ -1750,7 +1750,7 @@ int uv_os_uname(uv_utsname_t* buffer) { + } else { + /* Silence GetVersionEx() deprecation warning. */ + #ifdef _MSC_VER +- #pragma warning(suppress : 4996) ++ #pragma warning(disable : 4996) + #endif + if (GetVersionExW(&os_info) == 0) { + r = uv_translate_sys_error(GetLastError()); +-- +2.36.1 + diff --git a/upstream_utils/update_libuv.py b/upstream_utils/update_libuv.py index 789d9c426e..c849530772 100755 --- a/upstream_utils/update_libuv.py +++ b/upstream_utils/update_libuv.py @@ -22,6 +22,7 @@ def main(): os.path.join(prefix, "0005-Use-roborio-time.patch"), os.path.join(prefix, "0006-Style-comments-cleanup.patch"), os.path.join(prefix, "0007-Squelch-GCC-12.1-warnings.patch"), + os.path.join(prefix, "0008-Fix-Win32-warning-suppression-pragma.patch"), ]) # Delete old install diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index 611730882e..ea5d5f4e6c 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -254,6 +254,7 @@ public interface Command { * @return the decorated command * @deprecated use {@link #endlessly()} instead. */ + @SuppressWarnings("removal") // PerpetualCommand @Deprecated(forRemoval = true, since = "2023") default PerpetualCommand perpetually() { return new PerpetualCommand(this); diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PerpetualCommand.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PerpetualCommand.java index 4ecda74876..9448ed0d30 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PerpetualCommand.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PerpetualCommand.java @@ -56,6 +56,7 @@ public class PerpetualCommand extends CommandBase { return m_command.runsWhenDisabled(); } + @SuppressWarnings("removal") // Command.perpetually() @Override public PerpetualCommand perpetually() { return this; diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp index 5b58739d0e..ff956ff7fa 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp @@ -87,7 +87,9 @@ SequentialCommandGroup Command::AndThen( } PerpetualCommand Command::Perpetually() && { + WPI_IGNORE_DEPRECATED return PerpetualCommand(std::move(*this).TransferOwnership()); + WPI_UNIGNORE_DEPRECATED } EndlessCommand Command::Endlessly() && { diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/PerpetualCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/PerpetualCommand.h index 208a8755cf..7d4c7aa4a9 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/PerpetualCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/PerpetualCommand.h @@ -31,8 +31,7 @@ namespace frc2 { * * @deprecated replace with EndlessCommand */ -class WPI_DEPRECATED("Replace with EndlessCommand") PerpetualCommand - : public CommandHelper { +class PerpetualCommand : public CommandHelper { public: /** * Creates a new PerpetualCommand. Will run another command in perpetuity, @@ -41,8 +40,10 @@ class WPI_DEPRECATED("Replace with EndlessCommand") PerpetualCommand * * @param command the command to run perpetually */ + WPI_DEPRECATED("Replace with EndlessCommand") explicit PerpetualCommand(std::unique_ptr&& command); + WPI_IGNORE_DEPRECATED /** * Creates a new PerpetualCommand. Will run another command in perpetuity, * ignoring that command's end conditions, unless this command itself is @@ -52,9 +53,11 @@ class WPI_DEPRECATED("Replace with EndlessCommand") PerpetualCommand */ template >>> + WPI_DEPRECATED("Replace with EndlessCommand") explicit PerpetualCommand(T&& command) : PerpetualCommand(std::make_unique>( std::forward(command))) {} + WPI_UNIGNORE_DEPRECATED PerpetualCommand(PerpetualCommand&& other) = default; diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java index b70f8db00e..8d26a0eff6 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java @@ -168,6 +168,7 @@ class CommandDecoratorTest extends CommandTestBase { } } + @SuppressWarnings("removal") // Command.perpetually() @Test void perpetuallyTest() { try (CommandScheduler scheduler = new CommandScheduler()) { @@ -184,6 +185,22 @@ class CommandDecoratorTest extends CommandTestBase { } } + @Test + void endlesslyTest() { + try (CommandScheduler scheduler = new CommandScheduler()) { + Command command = new InstantCommand(); + + Command perpetual = command.endlessly(); + + scheduler.schedule(perpetual); + scheduler.run(); + scheduler.run(); + scheduler.run(); + + assertTrue(scheduler.isScheduled(perpetual)); + } + } + @Test void unlessTest() { try (CommandScheduler scheduler = new CommandScheduler()) { diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/EndlessCommandTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/EndlessCommandTest.java new file mode 100644 index 0000000000..9ea067846e --- /dev/null +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/EndlessCommandTest.java @@ -0,0 +1,23 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package edu.wpi.first.wpilibj2.command; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +class EndlessCommandTest extends CommandTestBase { + @Test + void endlessCommandScheduleTest() { + try (CommandScheduler scheduler = new CommandScheduler()) { + EndlessCommand command = new EndlessCommand(new InstantCommand()); + + scheduler.schedule(command); + scheduler.run(); + + assertTrue(scheduler.isScheduled(command)); + } + } +} diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelRaceGroupTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelRaceGroupTest.java index 3201a52c63..3c5cec2a64 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelRaceGroupTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelRaceGroupTest.java @@ -137,8 +137,8 @@ class ParallelRaceGroupTest extends CommandTestBase { Command command1 = command1Holder.getMock(); MockCommandHolder command2Holder = new MockCommandHolder(true, system2); Command command2 = command2Holder.getMock(); - MockCommandHolder perpetualCommandHolder = new MockCommandHolder(true); - Command command3 = new PerpetualCommand(perpetualCommandHolder.getMock()); + MockCommandHolder endlessCommandHolder = new MockCommandHolder(true); + Command command3 = new EndlessCommand(endlessCommandHolder.getMock()); Command group1 = new SequentialCommandGroup(command1, command2); assertNotNull(group1); diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/PerpetualCommandTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/PerpetualCommandTest.java index f9e93a3110..6b9690bde8 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/PerpetualCommandTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/PerpetualCommandTest.java @@ -9,6 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; class PerpetualCommandTest extends CommandTestBase { + @SuppressWarnings("removal") // PerpetualCommand @Test void perpetualCommandScheduleTest() { try (CommandScheduler scheduler = new CommandScheduler()) { diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java index c9ae4b2820..24470c1f3e 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java @@ -36,7 +36,7 @@ class ScheduleCommandTest extends CommandTestBase { new SequentialCommandGroup(new InstantCommand(), scheduleCommand); scheduler.schedule(group); - scheduler.schedule(new InstantCommand().perpetually()); + scheduler.schedule(new InstantCommand().endlessly()); scheduler.run(); assertDoesNotThrow(scheduler::run); } diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp index 112f13dae2..801fb3dfe9 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp @@ -6,6 +6,7 @@ #include "CommandTestBase.h" #include "frc2/command/ConditionalCommand.h" +#include "frc2/command/EndlessCommand.h" #include "frc2/command/InstantCommand.h" #include "frc2/command/ParallelRaceGroup.h" #include "frc2/command/PerpetualCommand.h" @@ -93,7 +94,22 @@ TEST_F(CommandDecoratorTest, AndThen) { TEST_F(CommandDecoratorTest, Perpetually) { CommandScheduler scheduler = GetScheduler(); + WPI_IGNORE_DEPRECATED auto command = InstantCommand([] {}, {}).Perpetually(); + WPI_UNIGNORE_DEPRECATED + + scheduler.Schedule(&command); + + scheduler.Run(); + scheduler.Run(); + + EXPECT_TRUE(scheduler.IsScheduled(&command)); +} + +TEST_F(CommandDecoratorTest, Endlessly) { + CommandScheduler scheduler = GetScheduler(); + + auto command = InstantCommand([] {}, {}).Endlessly(); scheduler.Schedule(&command); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/EndlessCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/EndlessCommandTest.cpp new file mode 100644 index 0000000000..21099ae201 --- /dev/null +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/EndlessCommandTest.cpp @@ -0,0 +1,23 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#include "CommandTestBase.h" +#include "frc2/command/EndlessCommand.h" +#include "frc2/command/InstantCommand.h" + +using namespace frc2; +class EndlessCommandTest : public CommandTestBase {}; + +TEST_F(EndlessCommandTest, EndlessCommandSchedule) { + CommandScheduler scheduler = GetScheduler(); + + bool check = false; + + EndlessCommand command{InstantCommand([&check] { check = true; }, {})}; + + scheduler.Schedule(&command); + scheduler.Run(); + EXPECT_TRUE(scheduler.IsScheduled(&command)); + EXPECT_TRUE(check); +} diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/PerpetualCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/PerpetualCommandTest.cpp index 6254b85a34..b53835bc16 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/PerpetualCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/PerpetualCommandTest.cpp @@ -14,7 +14,9 @@ TEST_F(PerpetualCommandTest, PerpetualCommandSchedule) { bool check = false; + WPI_IGNORE_DEPRECATED PerpetualCommand command{InstantCommand([&check] { check = true; }, {})}; + WPI_UNIGNORE_DEPRECATED scheduler.Schedule(&command); scheduler.Run(); diff --git a/wpilibc/CMakeLists.txt b/wpilibc/CMakeLists.txt index 4c8dfde5fb..8c2c85ce9e 100644 --- a/wpilibc/CMakeLists.txt +++ b/wpilibc/CMakeLists.txt @@ -47,11 +47,6 @@ if (WITH_TESTS) wpilib_add_test(wpilibc src/test/native/cpp) target_include_directories(wpilibc_test PRIVATE src/test/native/include) target_link_libraries(wpilibc_test wpilibc gmock_main) - if (NOT MSVC) - target_compile_options(wpilibc_test PRIVATE -Wno-error) - else() - target_compile_options(wpilibc_test PRIVATE /WX-) - endif() if (NOT WITH_CSCORE) target_compile_definitions(wpilibc_test PRIVATE DYNAMIC_CAMERA_SERVER) # Add just the camera server include directory diff --git a/wpilibc/src/test/native/cpp/simulation/EncoderSimTest.cpp b/wpilibc/src/test/native/cpp/simulation/EncoderSimTest.cpp index be13ca5fce..7722ccc9f0 100644 --- a/wpilibc/src/test/native/cpp/simulation/EncoderSimTest.cpp +++ b/wpilibc/src/test/native/cpp/simulation/EncoderSimTest.cpp @@ -91,7 +91,9 @@ TEST(EncoderSimTest, Period) { auto cb = sim.RegisterPeriodCallback(callback.GetCallback(), false); sim.SetPeriod(123.456); EXPECT_EQ(123.456, sim.GetPeriod()); + WPI_IGNORE_DEPRECATED EXPECT_EQ(123.456, encoder.GetPeriod().value()); + WPI_UNIGNORE_DEPRECATED EXPECT_EQ(kDefaultDistancePerPulse / 123.456, encoder.GetRate()); EXPECT_TRUE(callback.WasTriggered()); @@ -110,7 +112,9 @@ TEST(EncoderSimTest, SetMaxPeriod) { DoubleCallback callback; auto cb = sim.RegisterMaxPeriodCallback(callback.GetCallback(), false); + WPI_IGNORE_DEPRECATED encoder.SetMaxPeriod(units::second_t{123.456}); + WPI_UNIGNORE_DEPRECATED EXPECT_EQ(123.456, sim.GetMaxPeriod()); EXPECT_TRUE(callback.WasTriggered()); diff --git a/wpilibcExamples/build.gradle b/wpilibcExamples/build.gradle index 975a301b12..b373657819 100644 --- a/wpilibcExamples/build.gradle +++ b/wpilibcExamples/build.gradle @@ -34,11 +34,6 @@ templatesTree.list(new FilenameFilter() { templatesMap.put(it, []) } -nativeUtils.platformConfigs.named(nativeUtils.wpi.platforms.roborio).configure { - cppCompiler.args.remove('-Wno-error=deprecated-declarations') - cppCompiler.args.add('-Werror=deprecated-declarations') -} - nativeUtils.platformConfigs.named(nativeUtils.wpi.platforms.windowsx64).configure { linker.args.remove('/DEBUG:FULL') cppCompiler.debugArgs.remove('/Zi') @@ -149,13 +144,6 @@ model { lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' lib project: ':wpinet', library: 'wpinet', linkage: 'shared' lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' - binary.tasks.withType(CppCompile) { - if (!(binary.toolChain in VisualCpp)) { - cppCompiler.args "-Wno-error=deprecated-declarations" - } else { - cppCompiler.args "/wd4996" - } - } if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { nativeUtils.useRequiredLibrary(binary, 'ni_link_libraries', 'ni_runtime_libraries') } diff --git a/wpilibcIntegrationTests/build.gradle b/wpilibcIntegrationTests/build.gradle index c46605d3df..1788bc576e 100644 --- a/wpilibcIntegrationTests/build.gradle +++ b/wpilibcIntegrationTests/build.gradle @@ -39,11 +39,6 @@ model { } } } - binary.tasks.withType(CppCompile) { - cppCompiler.args "-Wno-missing-field-initializers" - cppCompiler.args "-Wno-unused-variable" - cppCompiler.args "-Wno-error=deprecated-declarations" - } lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared' lib project: ':wpimath', library: 'wpimath', linkage: 'shared' lib project: ':ntcore', library: 'ntcore', linkage: 'shared' diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/simulation/EncoderSimTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/simulation/EncoderSimTest.java index 931c0fe00a..eebabeb5f8 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/simulation/EncoderSimTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/simulation/EncoderSimTest.java @@ -69,6 +69,7 @@ class EncoderSimTest { } } + @SuppressWarnings("deprecation") // Encoder.getPeriod() @Test void testPeriod() { HAL.initialize(500, 0); diff --git a/wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp b/wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp index 7a5dd2ef99..d9888aec79 100644 --- a/wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp +++ b/wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp @@ -1750,7 +1750,7 @@ int uv_os_uname(uv_utsname_t* buffer) { } else { /* Silence GetVersionEx() deprecation warning. */ #ifdef _MSC_VER - #pragma warning(suppress : 4996) + #pragma warning(disable : 4996) #endif if (GetVersionExW(&os_info) == 0) { r = uv_translate_sys_error(GetLastError()); diff --git a/wpiutil/src/main/native/include/wpi/deprecated.h b/wpiutil/src/main/native/include/wpi/deprecated.h index 6e6a3bf7ca..c5b4af27a2 100644 --- a/wpiutil/src/main/native/include/wpi/deprecated.h +++ b/wpiutil/src/main/native/include/wpi/deprecated.h @@ -9,4 +9,23 @@ #define WPI_DEPRECATED(msg) [[deprecated(msg)]] #endif +#ifndef WPI_IGNORE_DEPRECATED +#ifdef __GNUC__ +#define WPI_IGNORE_DEPRECATED \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif defined(_WIN32) +#define WPI_IGNORE_DEPRECATED _Pragma("warning(disable : 4996)") +#endif + +#endif + +#ifndef WPI_UNIGNORE_DEPRECATED +#ifdef __GNUC__ +#define WPI_UNIGNORE_DEPRECATED _Pragma("GCC diagnostic pop") +#elif defined(_WIN32) +#define WPI_UNIGNORE_DEPRECATED _Pragma("warning(default : 4996)") +#endif +#endif + #endif // WPIUTIL_WPI_DEPRECATED_H_