C++ – VC++ Compiler: How to determine the current warning level or overrides

compiler-warningspragmavisual c++

I've got a project where I've just discovered that warning C4244 (possible loss of data) is being suppressed. I strongly suspect that some crummy MS header is suppressing this warning and leaving it suppressed for all translation units that include said header, but I've not determined which of their myriad headers may be at fault.

So, like any other programming problem, I'd like to start by doing a binary search, printing out the current warning level and if possible any suppressed warnings in my main Pre Compiled Header.

Does anyone know what compiler directive I might use, or what approach I might be able to take that would give me that information?

I cannot tell you how obnoxious it is to find that my carefully constructed type declarations in my headers are failing to give a compiler warning when a caller violates the contract and tries to send me an integer instead of a signed byte (which has led to the current bug I'm trying to solve).

Thoughts?

NOTES:

Searches on #pragma through my entire solution come up with only balanced declarations of #pragma warning(disable:xxxx) followed by #pragma warning(default:xxxx). And none of those reference 4244.

Searches on 4244 throughout the entire solution return no matches (I never override that warning, nor do any of my included libraries, sub-projects, etc.).

Searches on 4244 throughout the entire MS include paths return a few references, that appear to be balanced, or almost so, depending on the #define symbols that were set before calling them. Hence my suspicion that MS is at fault (combined with prior history of MS doing sloppy work in their headers).

Best Answer

Another option is to add this

#pragma warning (defualt) 

at the top of the file right after the #includes This resets the warning to the defualt, discarding any ignore which might have been called.

On a different note, I find it highly unlikely that an Microsoft header would disable a warning.