annoying warning: class Foo only defines private ctor/dtor
Yotam Medini
yotam@avanticorp.com
Thu Oct 1 09:17:00 GMT 1998
Suggestion:
Using a class as a namespace-like wrapper should be legitimate.
I suggest to add a condition for issuing warnings:
warning: `class Foo' only defines a private destructor and has no friends
warning: `class Foo' only defines private constructors and has no friends
that the class also does not have public static methods.
The warning should then be modified to:
warning: `class Foo' only defines a private destructor
and has no friends or static public members.
warning: `class Foo' only defines private constructors
and has no friends or static public members.
Example:
------------------------------------------------------------------------
telaviv:1547> cat NmSpC.cc; g++ -v; g++ -c NmSpC.cc
class NmSpC
{
public:
static int magic();
private:
NmSpC();
NmSpC(const NmSpC&);
~NmSpC();
};
NmSpC::magic() {return 7;}
Reading specs from /site/seg/gcc-2.8.1/lib/gcc-lib/sparc-sun-solaris2.5/2.8.1/specs
gcc version 2.8.1
NmSpC.cc:9: warning: `class NmSpC' only defines a private destructor and has no friends
NmSpC.cc:9: warning: `class NmSpC' only defines private constructors and has no friends
------------------------------------------------------------------------
-- yotam
More information about the Gcc-bugs
mailing list