🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Dave Gillespie Tue, 22 Dec 1992 14:27
GCC 2.1 emits a bogus warning
#1451
Author: Dave Gillespie
Date: Tue, 22 Dec 1992 14:27
34 lines
1489 bytes
While porting some code I got the warning,

> warning: class `foo' only defines private constructors and
> has no friends

which gave me a scare until I realized the class *did* have a
static member function which called "new foo" using the private
constructor.  In fact, I notice the warning even appears if I
put the function body using "new" right there in the class
definition!

This warning should probably be suppressed when there are
any public static member functions in the class.

A sample file:

--------
class foo {
  int x;
  foo(int y) { x = y; }
public:
  static foo *make(int a) { return new foo(a); }
};
--------

As far as I know, there is no way to get gcc to suppress this
warning, short of using "-w" to suppress all warnings.  It
would be nice if there were a way to suppress specific warnings,
e.g., a #pragma or special comment that would suppress all
warnings on the following line, or a command-line option that
would suppress all warning messages whose text contains a given
string.

								-- Dave
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads