question

AndreiMirea-1725 avatar image
0 Votes"
AndreiMirea-1725 asked ·

Visual Studio 2019 temporarily enable warning disabled in project

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://docs.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.

vs-general
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DylanZhu-MSFT avatar image
0 Votes"
DylanZhu-MSFT answered ·

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.

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you.

0 Votes 0 ·