From owner-freebsd-hackers Thu Oct 17 16:12:45 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id QAA08137 for hackers-outgoing; Thu, 17 Oct 1996 16:12:45 -0700 (PDT) Received: from gargoyle.bazzle.com ([206.103.246.190]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id QAA08120 for ; Thu, 17 Oct 1996 16:12:27 -0700 (PDT) Received: from gargoyle.bazzle.com (localhost [127.0.0.1]) by gargoyle.bazzle.com (8.7.6/8.6.12) with SMTP id TAA22780; Thu, 17 Oct 1996 19:11:37 -0400 (EDT) Date: Thu, 17 Oct 1996 19:11:37 -0400 (EDT) From: "Eric J. Chet" To: Nate Williams cc: hackers@FreeBSD.org Subject: Re: C++ question In-Reply-To: <199610172119.PAA20617@rocky.mt.sri.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk 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