-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
With the latest Visual Studio 2022 Preview, stdext::checked_array_iterator
has been deprecated. This results in compile errors like the following when including cpprestsdk's containerstream.h header:
11>...\include\cpprest\containerstream.h(404,47): warning C4996: 'stdext::checked_array_iterator<char *>': 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_CXX17_DEPRECATION_WARNINGS to suppress this warning.
11>C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.38.33030\include\iterator(1472,1): message : see declaration of 'stdext::checked_array_iterator'
11>C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.38.33030\include\iterator(1472,1): message : class _DEPRECATE_STDEXT_ARR_ITERS checked_array_iterator { // wrap a pointer with checking
11>C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.38.33030\include\iterator(1472,1): message : ^
frederick-vs-ja, nrudakov, diablodale, gopalrander, Capelliexp and 3 more
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
<iterator>
: Modernize and deprecate(un)checked_array_iterator
microsoft/STL#3818frederick-vs-ja commentedon Sep 20, 2023
I'd like to copy the definition of
checked_array_iterator
into cpprestsdk's header (with de-_Uglification), if we don't want to rely on GSL or C++20 (forspan
).stdext::checked_array_iterator
#1769michaelrgibbs commentedon Nov 15, 2023
This is now a problem in VS2022 17.8.0 which was released today.
dylanclark commentedon Nov 30, 2023
Is there a path forward to getting this fix merged? If not, would a patch to silence the warning be welcomed in the vcpkg portfile for cpprestsdk? A number of projects I've worked on consume cpprestsdk from vcpkg. They treat warnings as errors and have had to silence the deprecation warning with the new compiler update.
OliverGlandberger commentedon Dec 14, 2023
For what it's worth, this is still an issue for us, and our current work around (for the poor souls unfortunate enough to have upgraded VS 2022 early), is to replace this (line 404 in containerstream.h):
std::copy(readBegin, readEnd, stdext::checked_array_iterator<_CharType*>(ptr, count));
To this:
std::span<_CharType> data_span(readBegin, readEnd);
std::copy(data_span.begin(), data_span.end(), ptr);
Remember to add
include <span>
as well, and you might have to modify the secondstd::copy
below under the neighboring#else
.ssingh-facilgo commentedon Dec 22, 2023
Hey @OliverGlandberger , i have issue :
Build failed with message C:\Users\ssing\Documents\Mobile_faciligo\facilgo-sales-app\node_modules.fmt\fmt-8.0.0\include\fmt\format.h(341,51): error C4996: 'stdext::checked_array_iterator<T*>': 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. [C:\Users\ssing\Documents\Mobile_faciligo\facilgo-sales-app\node_modules\react-native-windows\fmt\fmt.vcxproj]. Check your build configuration.
Command failed. Re-run the command with --logging for more information.
is there any solution for this?
ssingh-facilgo commentedon Dec 25, 2023
same happen with vs2022 17.8.3
robsadams commentedon Jan 5, 2024
Hey @OliverGlandberger , where is containerstream.h located? In my project, this file does not exist in Android.
hypetsch commentedon Jan 8, 2024
We are facing the same issue. A solution other than having to ignore the warning would be required.
joshuayoes commentedon Jan 10, 2024
ChatGPT response for how to apply
_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING
for all solutions in Visual Studio 17.8.4 that worked for me.Using Property Sheets in Visual Studio is a good way to apply settings like preprocessor definitions across multiple projects. Here's a step-by-step guide on how to create and apply a Property Sheet for the
_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING
preprocessor definition:Creating a Property Sheet
Open Visual Studio and a Project: Start by opening one of your projects in Visual Studio.
Open Property Manager: Go to
View
>Other Windows
>Property Manager
. This will open the Property Manager window, which lists all your projects and their respective property sheets.Add New Property Sheet:
Add New Property Sheet...
.GlobalSuppressions.props
, and save it in a common location where it can be accessed by all projects.Edit the Property Sheet:
Properties
.C/C++
>Preprocessor
.Preprocessor Definitions
, click on the dropdown and select<Edit...>
._SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING
to the list. Click OK.Save: Save the changes and close the property sheet properties.
Applying the Property Sheet to Other Projects
Open Other Projects: Open another project where you want to apply this property sheet.
Use Property Manager:
View
>Other Windows
>Property Manager
.Add Existing Property Sheet:
Add Existing Property Sheet...
.GlobalSuppressions.props
and select it.Apply and Repeat: The property sheet is now applied to this project. Repeat this step for each project where you want to apply the preprocessor definition.
Notes
This approach centralizes certain settings, making them easier to manage across multiple projects. It's especially useful in larger solutions with many projects.
robsadams commentedon Jan 12, 2024
Thanks @joshuayoes but this does not work..... when you open property manager, it says that there are no c/c++ projects and does not list my project in the property manager window so I can't click on it and add a property sheet. I believe this is because my project is react-native/javascript. Any ideas?
joshuayoes commentedon Jan 12, 2024
These are the steps I followed and the solution worked for. I am doing a React Native for Windows project.
This is the key part, each solution that uses C++ needs
_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING
inProperties
>C/C++
>Preprocessor
>Preprocessor Definitions
in order to compile:Example of how to get to properties on a solution:

Example of setting being applied:

I choose to do this via Property Sheets but you could also manually go through each solution.
joshuayoes commentedon Jan 12, 2024
I added
GlobalSupressions.prop
to my~/<PROJECT>/windows/<APPNAME>
directoryThen I added clicked
Add Existing Property Sheet
to each C++ solutionand navigated to the path of my
~/<PROJECT>/windows/<APPNAME>/GlobalSupressions.prop
.I did this for each solution and then it would compile both via the play button in Visual Studio and via
npx react-native run-windows
I'm sure there is a better way to do this, but I am not a C++ developer and this was the first option that worked for me.
skycat2216 commentedon Feb 7, 2024
17.8.6
No official fix for it
jezz, Microsoft
trasa commentedon Mar 5, 2024
Reproduced in 17.9.1
RooTender commentedon Apr 19, 2024
Same stuff in 17.9.6
laultman commentedon Aug 10, 2024
It is not an isolated problem. It is a breaking change to many libs that have used the now "non-standard" code construct. In my case, it is in header files that I don't own. I can fix the header but it is unreliable because other services use the same header in its previous. Further when I apply the workaround to silence the error, that error does in fact disappear to only lead to downstream errors related to the implementations of the template function that implements the non-standard code. See format.h.
RayKoopa commentedon Nov 13, 2024
Still an issue. Just another one on top of 2+ year old workarounds to get SignalR C++ to work properly 😐
alinaliBQ commentedon Mar 28, 2025
This is a breaking change to projects that treat warnings as errors.
Reproduced in 17.13.4.