MSVC STL and warnings

Started by
5 comments, last by Kylotan 22 years, 3 months ago
A little tip that one or two of you may find useful: The STL distributed with MSVC 5 and 6 causes a lot (and I mean a lot) of level 4 warnings, making it difficult to use this warning level in many C++ projects. One solution to this is to edit all the standard headers (the ones in the include directory that lack a .H extension) by adding #pragma warning(push, 3) in the #ifdef _MSC_VER section at the top, and #pragma warning(pop) in the corresponding #ifdef _MSC_VER section at the bottom. Adding these two simple lines of code should ensure that the warning level is set at 3 when compiling the STL headers, even if the rest of your project is compiling at warning level 4, which is useful for catching more subtle bugs. (Note: I''ve not found any problems with doing this, but I can''t guarantee it''ll work all the time. Back up your headers if you don''t feel confident that you can take out those 2 lines easily enough in the event of difficulty.) PS. While you''re altering those header files (and even if you''re not), apply the fixes from the site labelled MSVC Fixes in my signature. [ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]
Advertisement
They say v3.08 compiles with no warnings at level 4 - did they just push/pop the warning level, or did they actually address the warnings?
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
I do not know, since I am too poor to buy the update Hopefully they actually fixed most of them, although a massive proportion of the errors are signed/unsigned mismatches where they''re comparing a signed value to an unsigned ''size_type''. It might not be practical or efficient for them to force a cast in these cases when they can be pretty sure the values are in range if their algorithm is correct. So I wouldn''t be surprised if they just turned a few of the warnings off.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]
The dinkumware STL still uses #pragma''s push and pops to hide warnings, but sadly some of them still gets through sometimes.

The compiler should have a flag to disable a particular type of warning.
quote:Original post by Void
The compiler should have a flag to disable a particular type of warning.

#pragma warning( disable : 4786 ) 


[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
I meant globally across all files on the command line as a compilation flag.
Ah.

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

This topic is closed to new replies.

Advertisement