It show the many warning when develop the opencv code on visual studio

alice alice 100 Reputation points
2024-09-25T09:11:35.7833333+00:00

I install the opencv with lib and using opencv on my cmake project with vs2022.

It always show the warning.

How can I close it for only opencv

User's image

Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | C++
Developer technologies | Visual Studio | Other
{count} votes

2 answers

Sort by: Most helpful
  1. alice alice 100 Reputation points
    2024-10-09T12:35:00.8733333+00:00

  2. Minxin Yu 13,506 Reputation points Microsoft External Staff
    2024-10-10T09:23:35.55+00:00

    Hi,

    In main.cpp

    Use

    #pragma warning(disable : xxx)
    

    E.g.

    #pragma warning(push, 0) 
    #pragma warning(disable : 26439)
    #pragma warning(disable : 26495)
    #include <opencv2/opencv.hpp>
    #pragma warning(pop)
    

    Now:

    enter image description here

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.