Flag  -Weffc++ in GCC (C++ only) is fairly helpful in detecting various violations of the following style guidelines from Scott Meyers’s “Effective C++” book:

  • Item 11:  Define a copy constructor and an assignment operator for classes with dynamically allocated memory.
  • Item 12:  Prefer initialization to assignment in constructors.
  • Item 14:  Make destructors virtual in base classes.
  • Item 15:  Have “operator=” return a reference to *this.
  • Item 23:  Don’t try to return a reference when you must return an object.

And the following style guidelines from Scott Meyers’ “More Effective C++” book:

  • Item 6:  Distinguish between prefix and postfix forms of increment and decrement operators.
  • Item 7:  Never overload “&&”, “||”, or “,”.

When selecting this option, be aware that the standard library headers do not obey all of these guidelines; use grep -v to filter out those warnings.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s