# Opencv warning on visual studio 2022

**URL:** <https://forum.opencv.org/t/opencv-warning-on-visual-studio-2022/18867>\
**Category:** C++\
**Tags:** build\
**Created:** [September 30, 2024, 12:55pm UTC](https://forum.opencv.org/t/opencv-warning-on-visual-studio-2022/18867 "2024-09-30T12:55:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sea\_Sea](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/sea_sea/32/11091_2.png) [@Sea\_Sea](https://forum.opencv.org/u/Sea_Sea)\
**Post date:** [September 30, 2024, 12:55pm UTC](https://forum.opencv.org/t/opencv-warning-on-visual-studio-2022/18867/1 "2024-09-30T12:55:14Z")

</div>

Just build it on visual studio 2022 and you will see warning.

And I want to close these warning or solve it.

It show the C:\opencv\include\opencv2\core\matx.inl.hpp  
I don’t know where it is be used for matx.inl.hpp on the git project

> **[GitHub - JustasBart/yolov8\_CPP\_Inference\_OpenCV\_ONNX](https://github.com/JustasBart/yolov8_CPP_Inference_OpenCV_ONNX)**
>
> Contribute to JustasBart/yolov8\_CPP\_Inference\_OpenCV\_ONNX development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [September 30, 2024, 1:22pm UTC](https://forum.opencv.org/t/opencv-warning-on-visual-studio-2022/18867/2 "2024-09-30T13:22:14Z")

</div>

> [@Sea\_Sea](#):
>
> and you will see warning.

please **show** us . else we cannot help !

(please paste **the exact** warning, along with the **exact** code line here)

also, which opencv version is it ?

---

<div class="post-metadata">

**Author:** ![Sea\_Sea](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/sea_sea/32/11091_2.png) [@Sea\_Sea](https://forum.opencv.org/u/Sea_Sea)\
**Post date:** [October 1, 2024, 12:06am UTC](https://forum.opencv.org/t/opencv-warning-on-visual-studio-2022/18867/3 "2024-10-01T00:06:10Z")

</div>

build with x64-Release  
4.10.0

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [October 1, 2024, 6:44am UTC](https://forum.opencv.org/t/opencv-warning-on-visual-studio-2022/18867/4 "2024-10-01T06:44:11Z")

</div>

first, please do not post screenshots of your ide here, but TEXT, ty.

however, it seems, you found a (minor) bug in the `MatStep` code,  
which can be even reproduced w/o opencv headers as a [MRE](https://stackoverflow.com/help/minimal-reproducible-example) :

```auto
struct MatStep {
  size_t *p;
  size_t buf[2];
  MatStep() {
      p = buf; // problem is here, buf is not initialized
      p[0] = p[1] = 0;
  }
};

int main() { MatStep m; return 0;} 

```

though it’s already [mentioned here](https://github.com/opencv/opencv/issues/16330),  
maybe raise a new issue on gh ?  
(also [see discussion here](https://github.com/opencv/opencv/issues/26137))

again, it’s a minor warning, and imho you’re safe to ignore it in your code

thanks for the report, nonetheless ! 😉

---

<div class="post-metadata">

**Author:** ![Sea\_Sea](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/sea_sea/32/11091_2.png) [@Sea\_Sea](https://forum.opencv.org/u/Sea_Sea)\
**Post date:** [October 1, 2024, 7:30am UTC](https://forum.opencv.org/t/opencv-warning-on-visual-studio-2022/18867/5 "2024-10-01T07:30:21Z")

</div>

Thanks,  
Yes, it is just a warning, do you have the method to close opencv warning?  
I can’t ignore the warning because I want to use the warning windows on vs 2022 IDE  
to develop my code.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [October 1, 2024, 8:40am UTC](https://forum.opencv.org/t/opencv-warning-on-visual-studio-2022/18867/6 "2024-10-01T08:40:13Z")

</div>

imo you got 2 options:

- fix the library (for everyone, the _proper_ way)  
(that is: raise an issue, start a disussion, send a pr with a fix)  
maybe just changing the order does it:

- suppress the warning (terrible idea, otherwise):  
add a `#pragma warning( disable: 26495 )` before including opencv headers

besides that:

> [@Sea\_Sea](#):
>
> I can’t ignore the warning because I want to use the warning windows on vs 2022 IDE  
> to develop my code.

this is not a valid argument.
