Visual Studio 2019 temporarily enable warning disabled in project

asked 2021-03-19T13:48:19.013+00:00
Andrei Mirea 41 Reputation points

Hi. Is there a way to disable an arbitrary warning in project and only enabling it in certain parts of code?
I mean something like

#pragma warning disable C26451   
// code  
#pragma warning restore C26451  

but instead of enable by default and disable explicitly, disable by default and enable explicitly. I couldn't find "enable" in https://learn.microsoft.com/en-us/cpp/preprocessor/warning?view=msvc-160 but maybe there's a way to achieve this with push/pop, levels or otherwise.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
2,399 questions
{count} votes

Accepted answer
  1. answered 2021-03-22T02:54:15.553+00:00
    Dylan Zhu-MSFT 6,346 Reputation points

    Hi AndreiMirea,

    After my research, temporarily enabling warning which is disabled is not supported. We suggest you can submit it as a suggestion in developer community: https://developercommunity.visualstudio.com/report?space=8&entry=suggestion

    Best Regards. Dylan

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our * *documentation* to enable e-mail notifications if you want to receive the related email notification for this thread.**


0 additional answers

Sort by: Most helpful