Wednesday, December 15, 2010

How Do I Become Warning Free?

If you’re starting a new project from scratch, writing warningfree code is easy. But if you’re starting from an existing codebase, it can be much less straightforward. The chances are that the first time you increase your compiler’s warning level or run a new tool, you will disappear under a tidal wave of warnings. Often these result from systemic issues with the code—common mistakes you’ve made over and over again, which have gone unnoticed until now, but each instance of which generates a warning. There are also issues that tend to “percolate” through the code generating many warnings (const-correctness in C++ is a classic example).

The solution is to be pragmatic. Most static analysis tools provide fine-grained control over which warnings are generated where (via comments embedded in the source code, for example). Very often you can get the number down to a manageable level by switching off the one or two warnings that account for the majority or by excluding a “problem” module. You can go back and fix these other warnings at a later date, but you gain most of the benefit of static analysis in the interim.

The same approach can help on the rare occasions where a buggy tool generates spurious warnings for legitimate code, where you knowingly choose to write “questionable” code, or where a third-party library generates warnings.

Source of Information :  Paul Butcher - Debug it Find repair and prevent bugs
How Do I Become Warning Free?SocialTwist Tell-a-Friend
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

0 comments: on "How Do I Become Warning Free?"

Post a Comment