Math-Linux.com

Knowledge base dedicated to Linux and applied mathematics.

Home > C++ > FAQ C++ > FAQ C++ - gcc/g++ > g++ compilation option -Weffc++

g++ compilation option -Weffc++

The following -W... options is not affected by -Wall.

 -Weffc++ (C++ and Objective-C++ only)
Warn about violations of the following style guidelines from Scott Meyers’ 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.

Also warn about violations of 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.

Also in this section

  1. Build in release mode with full optimizations in gcc / g++
  2. Code that compiles with gcc but not g++
  3. Disable all gcc / g++ warnings
  4. g++ compilation option -Weffc++
  5. gcc / g++ find where a header file is included from
  6. gcc / g++ how to dump all preprocessor definitions
  7. gcc / g++ preprocessor flags for the compiler version number
  8. gcc /g++ Why some variables are not detected as not used during compilation?
  9. Undefined Symbol ___gxx_personality_v0