microsoft / react-native-windows

A framework for building native Windows apps with React.
https://microsoft.github.io/react-native-windows/
Other
16.3k stars 1.14k forks source link

Build Error C4996 #12592

Closed tero-paananen closed 9 months ago

tero-paananen commented 9 months ago

Problem Description

I installed RNW via install script https://microsoft.github.io/react-native-windows/docs/rnw-dependencies on my new Windows 11 device. Script installed latest VS 2022 17.8.x with MSVC latest (14.38.x) and that MSVC is the problem with error

Severity    Code    Description Project File    Line    Suppression State   Details
Error   C4996   'stdext::checked_array_iterator<T *>::pointer': warning STL4043: stdext::checked_array_iterator, stdext::unchecked_array_iterator, and related factory functions are non-Standard extensions and will be removed in the future. std::span (since C++20) and gsl::span can be used instead. You can define _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING or _SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS to suppress this warning.
        with
        [
            T=wchar_t
        ]   Microsoft.ReactNative   C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\__msvc_iter_core.hpp  491     

I did not managed to get event simple hello world to build.

Now i try to install older VS 2022 17.7.x with older MSVC 14.37.x to get project build. Let see how it goes.

Any help from @asklar ? I found this issue https://github.com/microsoft/react-native-windows/issues/6918

Steps To Reproduce

  1. Install latest VC 2022 into Windows 11
  2. Make RNW 0.71.x HelloWorld and try to build

Expected Results

No response

CLI version

npx react-native -v

Environment

System:
    OS: Windows 11 10.0.22621
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 16.86 GB / 31.71 GB
  Binaries:
    Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.15 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
    Windows SDK:
      AllowDevelopmentWithoutDevLicense: Enabled
      AllowAllTrustedApps: Enabled
      Versions: 10.0.18362.0, 10.0.19041.0
  IDEs:
    Android Studio: Not Found
    Visual Studio: 16.11.31911.196 (Visual Studio Community 2019)
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: Not Found
    react-native: 0.71.13 => 0.71.13
    react-native-windows: 0.71.43 => 0.71.43
  npmGlobalPackages:
    *react-native*: Not Found
info React Native v0.73.2 is now available (your project is running on v0.71.13).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.73.2
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.71.13
info For more info, check out "https://reactnative.dev/docs/upgrading".

( I had VS 2022 uninstalled when i ran info command )

Target Platform Version

None

Target Device(s)

Desktop

Visual Studio Version

Visual Studio 2022

Build Configuration

Debug

Snack, code example, screenshot, or link to a repository

No response

tero-paananen commented 9 months ago

I did not managed to install older VS 2022 17.7 Community version. Installing older versions seems to be supported only Pro and Enterprise. I remembered that i have somehow previously installed older VS versions but not managed now...so i have to continue with latest VS 2022 17.8.4

tero-paananen commented 9 months ago

I managed to build project when adding compiler Preprocessor definitions flag _SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS into following projects: Folly, Microsoft.ReactNative, fmt (example below).
PreprocessorDefinitions

But what would be the best solution for this? Can i set this flag for example somehow into ExperimentalFeatures.props ?

asklar commented 9 months ago

Hi @tero-paananen, I don't work on this project anymore but you are in good hands with @chrisglein's team :)

chrisglein commented 9 months ago

Belief is that this was an issue that was fixed (warning looks familiar: https://github.com/microsoft/react-native-windows/pull/12411), but might not have been backported to 0.71 (it only made it to 0.72). Is it a requirement that you're on 0.71? Can you move to latest and get that fix?

tero-paananen commented 9 months ago

Latest (RNW 0.73.4) HelloWorld seems indeed not has this issue. I tested with this app:

npx react-native@latest init HelloLatest
cd HelloLatest
npx react-native-windows-init --overwrite --language cs
yarn install
npx react-native autolink-windows

I try to patch our current 0.71.x and continue with that still a while. I hope that patching only fmt (version & hash) would be enought.

jonthysell commented 5 months ago

Finally fixed this with https://github.com/microsoft/react-native-windows/pull/13178