{"id":1831,"date":"2010-12-13T20:01:02","date_gmt":"2010-12-14T02:01:02","guid":{"rendered":"http:\/\/www.realtimerendering.com\/blog\/?p=1831"},"modified":"2010-12-13T20:01:02","modified_gmt":"2010-12-14T02:01:02","slug":"cppcheck-free-easy-and-great","status":"publish","type":"post","link":"https:\/\/www.realtimerendering.com\/blog\/cppcheck-free-easy-and-great\/","title":{"rendered":"cppcheck: free, easy, and great"},"content":{"rendered":"<p>Jari Komppa pointed this tool out to me while we were talking about my previous post on <a href=\"http:\/\/www.realtimerendering.com\/blog\/gdebugger-is-now-free\/\">gDEBugger being free<\/a>. The tool: <a href=\"http:\/\/sourceforge.net\/apps\/mediawiki\/cppcheck\/index.php?title=Main_Page\">cppcheck<\/a> (download <a href=\"http:\/\/sourceforge.net\/projects\/cppcheck\/\">here<\/a>). It&#8217;s free, it&#8217;s very simple to use, and it&#8217;s effective. Install, then run it like so:<\/p>\n<p style=\"padding-left: 30px;\">cppcheck -q <em>theRootDirectoryOfAllCodeYouWantToCheck<\/em><\/p>\n<p>It will then plow through all your C++ files in this directory on down and look for memory allocation\/deallocation problems, use of unallocated array elements, and other defects. &#8220;-q&#8221; means &#8220;show me just the errors found&#8221;.\u00a0It does the things your compiler should find but probably doesn&#8217;t (someone will no doubt correct me about this for gcc or somesuch, but \u00a0I use MS Visual Studio and it&#8217;s definitely true for that). For our current project it found about 15 problems, one pretty serious. For an investment of just a few minutes, this free tool caught a number of flaws that weren&#8217;t getting caught by other means. One particularly nice feature is that it tries all possible &#8220;#ifdef&#8221; paths, checking to see if any combinations cause code problems like undefined variables or similar.<\/p>\n<p>I particularly love the fact that I didn&#8217;t have to do the usual thing of telling it all about the various include file paths and the eighteen other things I usually have to do to get similar programs working. It was so easy to run that I spent a whole two minutes more and tried it on another group&#8217;s project for which I had the code. It turned up a bunch of spots where the codebase needs some repair. Nice! About the only drawback is that the error messages are sometimes a bit terse and take some decoding. It&#8217;s open source, and they have specifically asked for help with documentation, so I expect this area will improve over time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Jari Komppa pointed this tool out to me while we were talking about my previous post on gDEBugger being free. The tool: cppcheck (download here). It&#8217;s free, it&#8217;s very simple to use, and it&#8217;s effective. Install, then run it like so: cppcheck -q theRootDirectoryOfAllCodeYouWantToCheck It will then plow through all your C++ files in this [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[322,429,98],"class_list":["post-1831","post","type-post","status-publish","format-standard","hentry","category-resources","tag-c","tag-memory","tag-tools"],"_links":{"self":[{"href":"https:\/\/www.realtimerendering.com\/blog\/wp-json\/wp\/v2\/posts\/1831","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.realtimerendering.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.realtimerendering.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.realtimerendering.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.realtimerendering.com\/blog\/wp-json\/wp\/v2\/comments?post=1831"}],"version-history":[{"count":1,"href":"https:\/\/www.realtimerendering.com\/blog\/wp-json\/wp\/v2\/posts\/1831\/revisions"}],"predecessor-version":[{"id":1832,"href":"https:\/\/www.realtimerendering.com\/blog\/wp-json\/wp\/v2\/posts\/1831\/revisions\/1832"}],"wp:attachment":[{"href":"https:\/\/www.realtimerendering.com\/blog\/wp-json\/wp\/v2\/media?parent=1831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.realtimerendering.com\/blog\/wp-json\/wp\/v2\/categories?post=1831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.realtimerendering.com\/blog\/wp-json\/wp\/v2\/tags?post=1831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}