help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strange error "changes meaning ..."


From: Paul Pluzhnikov
Subject: Re: strange error "changes meaning ..."
Date: 29 Jan 2005 12:07:41 -0800
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence)

jk <joerg-at-ibk@web.de> writes:

> the example where it occurs is already minimal

No, it isn't. Here is a much shorter one:

struct Foo { };
struct Bar {
   Foo f;
   int Foo;
};

The above fails with the same error message with g++ 2.95, 3.3,
3.3.2, 3.4.3 and '4.0.0 20040919 (experimental)'.

Surprisingly, it succeeds with gcc-3.4.0.

The HP aCC produces a more informative message:
$ aCC -c junk.cc
Error 439: "junk.cc", line 4 # Name 'Foo' was redefined after its
   use in a class. A previous declaration used struct Foo ["junk.cc", line 1].
      int Foo;
          ^^^ 

Ditto IBM's xlC:
$ xlC -c junk.cc
"junk.cc", line 4.7: 1540-0416 (S) "Foo" cannot be declared because its name has
 already been used.

The solution is trivial: replace

    Consumer::Consumer Consumer;

with

    Consumer::Consumer consumer;    // or
    Consumer::Consumer consumer_;   // or
    Consumer::Consumer theConsumer; // or

Note, that one of the widely-accepted naming conventions is to use
types that begin with a capital letter and variables that do not.
Naming both variables and types the same is certainly confusing,
and generally considered a bad style (TM).

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]