From 8eb0617d95e709ed88e36a2b0eb52d8fbea331b8 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Wed, 18 Oct 2023 17:24:52 -0700 Subject: [PATCH] Build with MSVC /W4 (#41044) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41044 The reference Clang/GCC build has a pretty strict set of warnings enabled. The reference MSVC build has less strict warnings, which can be a problem for MSVC users building at higher warning levels (e.g. React Native for Windows in OSS uses `/W4` as its baseline warning level). This bumps up the MSVC warning level to `/W4`, since we are nearly clean already. There are some limitations. E.g. we don't test binary with MSVC (some issues I didn't work out), and only test building statically linked. But but we do have a minimal C benchmark we compile with MSVC. X-link: https://github.com/facebook/yoga/pull/1432 Test Plan: GitHub Actions running benchmark MSVC build. Reviewed By: yungsters Differential Revision: D50398443 Pulled By: NickGerleman fbshipit-source-id: 6616034d79b1a308b32d5d3387bae70f40b7b5ab --- .../react-native/ReactCommon/yoga/cmake/project-defaults.cmake | 2 +- .../react-native/ReactCommon/yoga/yoga/bits/NumericBitfield.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactCommon/yoga/cmake/project-defaults.cmake b/packages/react-native/ReactCommon/yoga/cmake/project-defaults.cmake index 08f50a4eced8f5..c262bac8af89af 100644 --- a/packages/react-native/ReactCommon/yoga/cmake/project-defaults.cmake +++ b/packages/react-native/ReactCommon/yoga/cmake/project-defaults.cmake @@ -17,7 +17,7 @@ add_compile_options( # "Standard C++ exception handling" (C++ stack unwinding including extern c) /EHsc # Enable warnings and warnings as errors - /W3 + /W4 /WX # Disable RTTI $<$:/GR-> diff --git a/packages/react-native/ReactCommon/yoga/yoga/bits/NumericBitfield.h b/packages/react-native/ReactCommon/yoga/yoga/bits/NumericBitfield.h index 63f7eb657bb6aa..d6102409b2b787 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/bits/NumericBitfield.h +++ b/packages/react-native/ReactCommon/yoga/yoga/bits/NumericBitfield.h @@ -34,7 +34,7 @@ template < typename Enum, std::enable_if_t<(ordinalCount() > 0), bool> = true> constexpr uint8_t minimumBitCount() { - return details::log2ceilFn(ordinalCount() - 1); + return details::log2ceilFn(static_cast(ordinalCount() - 1)); } template