From ba4ec6c9677b096d23d2a2d261b32dbfef55deef Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Sat, 17 Sep 2022 00:23:59 -0700 Subject: [PATCH] [build] Fix clang-tidy false positive on Linux (#4406) * Fix clang-tidy false positive on Linux ``` == clang-tidy /home/tav/frc/wpilib/allwpilib/wpiutil/src/main/native/windows/StackTrace.cpp == /home/tav/frc/wpilib/allwpilib/wpiutil/src/main/native/windows/StackTrace.cpp:12:33: error: expected class name [clang-diagnostic-error] class StackTraceWalker : public StackWalker { ^ /home/tav/frc/wpilib/allwpilib/wpiutil/src/main/native/windows/StackTrace.cpp:16:17: error: unknown type name 'LPCTSTR' [clang-diagnostic-error] void OnOutput(LPCTSTR szText) override; ^ /home/tav/frc/wpilib/allwpilib/wpiutil/src/main/native/windows/StackTrace.cpp:23:33: error: unknown type name 'LPCTSTR' [clang-diagnostic-error] void StackTraceWalker::OnOutput(LPCTSTR szText) { ^ ``` * Fix false positives for macOS code --- wpinet/src/main/native/macOS/MulticastServiceResolver.cpp | 4 ++++ wpinet/src/main/native/macOS/ResolverThread.cpp | 4 ++++ wpinet/src/main/native/macOS/ResolverThread.h | 4 ++++ wpiutil/src/main/native/windows/StackTrace.cpp | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/wpinet/src/main/native/macOS/MulticastServiceResolver.cpp b/wpinet/src/main/native/macOS/MulticastServiceResolver.cpp index 135a4a3de1..eecf819814 100644 --- a/wpinet/src/main/native/macOS/MulticastServiceResolver.cpp +++ b/wpinet/src/main/native/macOS/MulticastServiceResolver.cpp @@ -2,6 +2,8 @@ // 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. +#if defined(__APPLE__) + #include "wpinet/MulticastServiceResolver.h" #include @@ -212,3 +214,5 @@ void MulticastServiceResolver::Stop() { pImpl->ResolveStates.clear(); pImpl->serviceRef = nullptr; } + +#endif // defined(__APPLE__) diff --git a/wpinet/src/main/native/macOS/ResolverThread.cpp b/wpinet/src/main/native/macOS/ResolverThread.cpp index c47d1722c9..14526709e1 100644 --- a/wpinet/src/main/native/macOS/ResolverThread.cpp +++ b/wpinet/src/main/native/macOS/ResolverThread.cpp @@ -2,6 +2,8 @@ // 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. +#if defined(__APPLE__) + #include "ResolverThread.h" #include @@ -109,3 +111,5 @@ std::shared_ptr ResolverThread::Get() { } return locked; } + +#endif // defined(__APPLE__) diff --git a/wpinet/src/main/native/macOS/ResolverThread.h b/wpinet/src/main/native/macOS/ResolverThread.h index 3c4e3d3a0d..158cda832d 100644 --- a/wpinet/src/main/native/macOS/ResolverThread.h +++ b/wpinet/src/main/native/macOS/ResolverThread.h @@ -2,6 +2,8 @@ // 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. +#if defined(__APPLE__) + #pragma once #include @@ -44,3 +46,5 @@ class ResolverThread { std::atomic_bool running; }; } // namespace wpi + +#endif // defined(__APPLE__) diff --git a/wpiutil/src/main/native/windows/StackTrace.cpp b/wpiutil/src/main/native/windows/StackTrace.cpp index bab5f83511..de31b2a256 100644 --- a/wpiutil/src/main/native/windows/StackTrace.cpp +++ b/wpiutil/src/main/native/windows/StackTrace.cpp @@ -8,6 +8,8 @@ #include "wpi/ConvertUTF.h" #include "wpi/SmallString.h" +#if defined(_MSC_VER) + namespace { class StackTraceWalker : public StackWalker { public: @@ -40,3 +42,5 @@ std::string GetStackTraceDefault(int offset) { } } // namespace wpi + +#endif // defined(_MSC_VER)