From owner-freebsd-hackers Wed Sep 13 16:59: 4 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from wall.polstra.com (rtrwan160.accessone.com [206.213.115.74]) by hub.freebsd.org (Postfix) with ESMTP id 71E3337B423 for ; Wed, 13 Sep 2000 16:59:01 -0700 (PDT) Received: from vashon.polstra.com (vashon.polstra.com [206.213.73.13]) by wall.polstra.com (8.9.3/8.9.3) with ESMTP id QAA29589; Wed, 13 Sep 2000 16:58:53 -0700 (PDT) (envelope-from jdp@polstra.com) From: John Polstra Received: (from jdp@localhost) by vashon.polstra.com (8.9.3/8.9.1) id QAA01085; Wed, 13 Sep 2000 16:58:53 -0700 (PDT) (envelope-from jdp@polstra.com) Date: Wed, 13 Sep 2000 16:58:53 -0700 (PDT) Message-Id: <200009132358.QAA01085@vashon.polstra.com> To: hackers@freebsd.org Cc: archie@whistle.com Subject: Re: c++ error In-Reply-To: <200009132234.PAA87368@bubba.whistle.com> References: <200009132234.PAA87368@bubba.whistle.com> Organization: Polstra & Co., Seattle, WA Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In article <200009132234.PAA87368@bubba.whistle.com>, Archie Cobbs wrote: > This happens on 4.1-RELEASE: > > $ c++ ... foo.cc > > /usr/include/netinet/in.h:303: ANSI C++ forbids data member `ip_opts' with same name as enclosing class > *** Error code 1 > > Any ideas? I tried __BEGIN_DECLS and __END_DECLS but that didn't help. > I'm not a C++ expert. > > $ c++ --version > $ 2.95.2 I can't duplicate it with this "program": #include #include I compile it with "cc -c test.cc" and get no errors. The diagnostic is valid, but there is a kludge in the compiler to make it work anyway. See "src/contrib/gcc.295/cp/decl.c" around line 11515: /* 9.2p13 [class.mem] */ if (declarator == constructor_name (current_class_type) /* Divergence from the standard: In extern "C", we allow non-static data members here, because C does and /usr/include/netinet/in.h uses that. */ && (staticp || ! in_system_header)) cp_pedwarn ("ANSI C++ forbids data member `%D' with same name as enclosing class", declarator); Notice that it is permissive if the declaration is in a "system header". This seems to work right, because if I create a local directory "netinet" containing a copy of "in.h" and add "-I." to the command line, then I get the diagnostic. Is this the standard compiler installation, or are you using the ports version? If it's the ports version, maybe it has an incorrect notion of where the system headers are. I ran my tests using the standard FreeBSD compiler installation. John -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Disappointment is a good sign of basic intelligence." -- Chögyam Trungpa To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message