From owner-freebsd-hackers Thu Oct 17 14:21:15 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id OAA00762 for hackers-outgoing; Thu, 17 Oct 1996 14:21:15 -0700 (PDT) Received: from rocky.mt.sri.com (rocky.mt.sri.com [206.127.76.100]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id OAA00756 for ; Thu, 17 Oct 1996 14:21:11 -0700 (PDT) Received: (from nate@localhost) by rocky.mt.sri.com (8.7.5/8.7.3) id PAA20617; Thu, 17 Oct 1996 15:19:51 -0600 (MDT) Date: Thu, 17 Oct 1996 15:19:51 -0600 (MDT) Message-Id: <199610172119.PAA20617@rocky.mt.sri.com> From: Nate Williams To: hackers@freebsd.org Subject: C++ question Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Any C++ gurus out here? If so, here's a small snippet of a program that I am having some questions on. ------------cut here--------------- class foo { public: foo() {}; private: struct A { int bigint; }; struct B { A *ptr; // Sun's C++ compiler doesn't like this }; A myints; A *getint(void); }; #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) { return ( &myints ); } ------------cut here---------------- 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. It's only a warning, but according to the documentation I'm doing something that won't be allowed in future C++ releases. 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++. Any clues? Finally, I find it interesting that G++ and Sun's CC compiler have completely different function declaration syntax when you return structures defined inside the function. Nate