Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdext::checked_array_iterator compilation error with VS 2022 17.8 Preview 2 #1768

Open
kobykahane opened this issue Sep 20, 2023 · 17 comments · May be fixed by #1769
Open

stdext::checked_array_iterator compilation error with VS 2022 17.8 Preview 2 #1768

kobykahane opened this issue Sep 20, 2023 · 17 comments · May be fixed by #1769

Comments

@kobykahane
Copy link

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
Copy link

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 (for span).

@michaelrgibbs
Copy link

This is now a problem in VS2022 17.8.0 which was released today.

@dylanclark
Copy link

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
Copy link

OliverGlandberger commented 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 second std::copy below under the neighboring #else.

@ssingh-facilgo
Copy link

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
Copy link

This is now a problem in VS2022 17.8.0 which was released today.

same happen with vs2022 17.8.3

@robsadams
Copy link

robsadams commented Jan 5, 2024

Hey @OliverGlandberger , where is containerstream.h located? In my project, this file does not exist in Android.

@hypetsch
Copy link

hypetsch commented Jan 8, 2024

We are facing the same issue. A solution other than having to ignore the warning would be required.

@joshuayoes
Copy link

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

  1. Open Visual Studio and a Project: Start by opening one of your projects in Visual Studio.

  2. 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.

  3. Add New Property Sheet:

    • Right-click on one of your projects in the Property Manager and choose Add New Property Sheet....
    • Give it a name, like GlobalSuppressions.props, and save it in a common location where it can be accessed by all projects.
  4. Edit the Property Sheet:

    • Once the property sheet is created, it will appear under the project in the Property Manager. Right-click on it and select Properties.
    • In the Property Pages dialog, navigate to C/C++ > Preprocessor.
    • Under Preprocessor Definitions, click on the dropdown and select <Edit...>.
    • Add _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING to the list. Click OK.
  5. Save: Save the changes and close the property sheet properties.

Applying the Property Sheet to Other Projects

  1. Open Other Projects: Open another project where you want to apply this property sheet.

  2. Use Property Manager:

    • Again, go to View > Other Windows > Property Manager.
    • Right-click on the project in the Property Manager.
  3. Add Existing Property Sheet:

    • Choose Add Existing Property Sheet....
    • Navigate to the location where you saved GlobalSuppressions.props and select it.
  4. 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

  • Consistency: Ensure that all projects that need the preprocessor definition have the property sheet applied.
  • Source Control: If you're using source control, remember to add the property sheet file to your repository.
  • Updates: Any changes made to the property sheet will automatically apply to all projects that include it.

This approach centralizes certain settings, making them easier to manage across multiple projects. It's especially useful in larger solutions with many projects.

@robsadams
Copy link

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
Copy link

joshuayoes commented 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 in Properties > C/C++ > Preprocessor > Preprocessor Definitions in order to compile:

Example of how to get to properties on a solution:
Screenshot 2024-01-12 at 12 27 18 PM

Example of setting being applied:
Screenshot 2024-01-12 at 12 25 21 PM

I choose to do this via Property Sheets but you could also manually go through each solution.

@joshuayoes
Copy link

joshuayoes commented Jan 12, 2024

I added GlobalSupressions.prop to my ~/<PROJECT>/windows/<APPNAME> directory

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup />
  <ItemDefinitionGroup>
    <ClCompile>
      <PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions);_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING;</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>
  <ItemGroup />
</Project>

Then I added clicked Add Existing Property Sheet to each C++ solution

Screenshot 2024-01-12 at 12 31 31 PM

and navigated to the path of my ~/<PROJECT>/windows/<APPNAME>/GlobalSupressions.prop.

Screenshot 2024-01-12 at 12 32 20 PM

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
Copy link

17.8.6
No official fix for it
jezz, Microsoft

@trasa
Copy link

trasa commented Mar 5, 2024

Reproduced in 17.9.1

@RooTender
Copy link

Same stuff in 17.9.6

@laultman
Copy link

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
Copy link

Still an issue. Just another one on top of 2+ year old workarounds to get SignalR C++ to work properly 😐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.