CodeWizard for Linux

November 1st, 1999 by Ben Crowder in

Codewizard is a tool that searches through your code for violations of good C++ coding standards.
Your rating: None
  • Manufacturer: ParaSoft

  • E-mail: info@parasoft.com

  • URL: http://www.parasoft.com/

  • Price: $2495 US (single license)

  • Reviewer: Ben Crowder

You're working on your latest C++ project, an infinitely cool piece of software that everyone is dying to see. Before you release, however, you want to get rid of as many bugs as possible. You know you have a certain bad habit you learned in C, the one you have to go back and fix time, after time since you keep forgetting you're writing in C++ now.

Enter CodeWizard by ParaSoft, a tool that searches through your code for violations of good C++ coding standards. Based on programming ideas from Scott Meyers' books Effective C++ and More Effective C++, CodeWizard automatically enforces thirty-five descriptive rules or “items” for effective C++ programming—standards that significantly reduce the number of errors in your code. In addition to Meyers' rules, ParaSoft has included a list of thirty-six additional items.

Figure 1. Rule Violation Message

What kind of rules are we talking about? First of all, the items have each been given a rating according to the severity of the rule. The five ratings, from least serious to fatal, are: Informational, Possible Violation, Violation, Possible Severe Violation and Severe Violation (see Figure 1). An example of an Informational rule is item 2 under the Effective C++ list: “Prefer iostream.h to stdio.h.” So, for instance, if you include stdio.h in your code, one of the warnings that will come up will explain that you shouldn't use stdio.h when coding in C++ (see Figure 2). A Possible Violation is rule #17: “Check for assignment to self in operator=.” Item #22 catalogs a Violation: “Pass and return objects by reference instead of by value.” A Possible Severe Violation is something like, “Don't try to return a reference when you must return an object.” Severe violations can prove to be fatal to your program. Rule #10 is a good example: “Write delete if you write new.” Seems obvious, of course, but you may forget it and thus cause ugly memory leaks. The items are divided into different categories, such as “Shifting from C to C++”, “Memory Management” and “Inheritance and Object-Oriented Design”.

Figure 2. C++ Code that Violates a Rule

CodeWizard came with some instructions on installation and basic usage. The distribution file is a tar file—it's up to you to manually copy it over from the CD and unpack it. A graphical installation program would come in handy for less experienced users (although you probably won't be using the UNIX version of CodeWizard, if you aren't familiar with a UNIX shell and basic commands). You can configure CodeWizard as either root or a regular user—both ways worked fine for me. A license is required, which must be obtained from ParaSoft. The pslic program, the ParaSoft License Manager, will give you a machine ID and a network ID, which you give to ParaSoft. In return, you'll receive an expiration date and a password which will unlock CodeWizard. I'm sure there's an easier way to manage licenses, one that doesn't require contacting ParaSoft, but this method minimizes pirating (which is, of course, a concern only for commercial software vendors—the GPL is beautiful in that it completely shatters software piracy).

You use CodeWizard in place of your compiler on the command line. Instead of typing

g++ project.c -o project

you would use

codewizard project.c -o project
You can set the compiler for CodeWizard to use in a configuration file. CodeWizard then scans your code for any of the violations in its rule set. On a side note, you can suppress any of the rules (in case some of them make no sense when applied to your particular project), or you can add your own rules using RuleWizard (see Figure 3). There is a Motif GUI program, Insra (see Figure 4), that displays the error messages and allows you to open the source files, make any necessary changes, rebuild the program and retest the code for violations. If you want to keep everything strictly console-based, however, you can do that as well.

Figure 3. Rule Wizard Screen

All in all, I'd have to say that CodeWizard can be an incredible help in C++ coding. A Java version is available as well, and with the ability to add your own rules, you could foreseeably use it for almost any other language as well. Though it is expensive, if you're serious about your C++, this would be a wise investment.Version 3.0 is due out in September.

Figure 4. Motif Program Insra

Ben Crowder is a young Linux aficionado living in Utah. In addition to fiddling with the insides of computers, Ben enjoys reading, writing and music. He can be reached at mlcrowd@enol.com.

__________________________


Special Magazine Offer -- 2 Free Trial Issues!
Receive 2 free trial issues of Linux Journal as well as instant online access to current and past issues. There's NO RISK and NO OBLIGATION to buy. CLICK HERE for offer

Linux Journal: delivering readers the advice and inspiration they need to get the most out of their Linux systems since 1994.

Sorry, offer available in the US only. International orders, click here.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

linux

On October 2nd, 2007 krux enigma ezb mp3 download (not verified) says:

is H. Anvin? Who Peter Thanks.

linux

On October 2nd, 2007 krux enigma ezb mp3 download (not verified) says:

is H. Anvin? Who Peter Thanks.

Featured Videos

Email is one of the least private and least secure forms of communication, although few people realize this. MixMaster is one way to allow secure, anonymous communication even over the very public medium of email. This tutorial will get you started with MixMaster quickly and easily.

In case you were wondering about the fun side of Linux World Expo, we thought we'd give you a peek at our shenanigans. We at Linux Journal love what we do so much, that we can't help but have a ball wherever we go.

From the Magazine

September 2008, #173

Feeling a bit like a Thermian? Never give up, never surrender! Someday, you could go from underdog to top dog. Just take a look at a few of the underdogs we highlight in this issue: Mutt, djbdns, Nginix, Gentoo, Xara and the program voted mostly likely to fail just a few years back—Firefox. If Firefox is not radical enough for you, check out Chef Marcel's column for some more alternatives. Having trouble mapping your program data to your relational database? If so, Rueven Lerner shows you some tricks in his At The Forge column.

Need to run GUI applications on your server in the next state? In his Paranoid Penguin column, Mick Bauer shows you how to do it securely. Kyle Rankin keeps hacking and slashing and shows you a few split screen secrets you may not be familiar with. Finally, we all know what happens next February, but only Doc knows what happens afterward.

Read this issue