Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] -Wshadow


On Wed, May 25, 2005 at 10:03:08AM +1000, John Clarke wrote:

> and for C++ I use:
> 
>     -Wall -W -Wpointer-arith -Wfloat-equal -Wcast-align -Wcast-qual
>     -Waggregate-return -Wno-unused-parameter -Wreorder
>     -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-non-template-friend

I don't do much C++ but -Weffc++ looks pretty cool.

       -Weffc++ (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 dynami-
               cally 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 Effec-
           tive C++ book:
           *   Item 6:  Distinguish between prefix and postfix forms of increment and decrement opera-
               tors.
           *   Item 7:  Never overload "&&", "||", or ",".
but:
           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.


Matt