Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Oct 1996 19:11:37 -0400 (EDT)
From:      "Eric J. Chet" <ejc@gargoyle.bazzle.com>
To:        Nate Williams <nate@mt.sri.com>
Cc:        hackers@FreeBSD.org
Subject:   Re: C++ question
Message-ID:  <Pine.BSF.3.95.961017184808.22111A-100000@gargoyle.bazzle.com>
In-Reply-To: <199610172119.PAA20617@rocky.mt.sri.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 17 Oct 1996, Nate Williams wrote:

> Any C++ gurus out here?  If so, here's a small snippet of a program that
> I am having some questions on.
> 
> #if __GNUC__
> foo::A *               // G++ requires this, but Sun's compiler gets lost
> #else
> A *                    // I prefer G++'s syntax above, but can't for Sun
> #endif
> 
> foo::getint(void)

Remember "A" only exists in foo's namespace.  The declaration
has to be:

	foo::A* foo::getint(void)

If the Sun compiler allows:

	A* foo::getint(void)

it has a problem.  Sun's compiler should return something like
"A* is undefined".  

> 
> The above snippet of code compiles fine with g++ and *all* warnings
> turned on, but gives the following warning with Sun's CC compiler
> (latest released version).
> 
> fly:/tmp % CC +w -c grpdgram.cc
> "grpdgram.cc", line 12: Warning (Anachronism): foo::A is not accessible from foo::B.

This is false, foo::A has been defined and is in the same
namespace as foo::B.

> 
> It's only a warning, but according to the documentation I'm doing
> something that won't be allowed in future C++ releases. 

I have not seen anything disallowing this in the latest public C++
draft. You can take a look at it: "http://www.cygnus.com/misc/wp/draft"

> 
> All I'm trying to do is define a structure, and then using the resulting
> definition in another structure.  (It's used for *simple* list
> processing in the real code, and I have a place-holder for multiple
> lists in another structure).  I know how to get rid of the warnings with
> the particular application (be more 'object oriented';), but I would
> think using two structures would be allowed in C++.

Maybe you can give me a little larger view of what your trying to
accomplish.  I can't remember the last time I had to define two nested
structs in a class.  I spend my workday doing OO development, implementing
in C++, If I can help I will.

Peace,
                                              Eric J. Chet
                                               - ejc@bazzle.com




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.961017184808.22111A-100000>