Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Visual Studio 2022, disable warnings from glm in C++

I’m writing a program using Vulkan and GLM in C++ on the Visual Studio 2022 IDE.

GLM produces 109 warnings. Each one looks like this:

Warning C26495  Variable 'glm::tvec4<unsigned char,0>::<unnamed-tag>::<unnamed-tag>::t' is uninitialized. Always initialize a member variable (type.6). 

I’m not interested in solving these warnings because I don’t want to change glm or other external dependencies. For reasons of clarity, however, I do not want to display these in the list of warnings. All other warnings should be displayed.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If the warning comes from a header, you can maybe do

#pragma warning( push ) 
#pragma warning( disable : 26495 ) 
#include "header" 
#pragma warning( pop )

This will save (push) the current warning settings, then disable the specific error (26495). After including the header file, it will then reset the warnings back to what they were before (pop) from when they were saved. Effectively, this disabled the warning throughout the header file.

If it’s from a specific line of your code, you can do

#pragma warning( suppress : 26495 )

suppress is a way to disable a warning for only the next line of code.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading