Date: Wed, 13 Sep 2000 16:58:53 -0700 (PDT) From: John Polstra <jdp@polstra.com> To: hackers@freebsd.org Cc: archie@whistle.com Subject: Re: c++ error Message-ID: <200009132358.QAA01085@vashon.polstra.com> In-Reply-To: <200009132234.PAA87368@bubba.whistle.com> References: <200009132234.PAA87368@bubba.whistle.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In article <200009132234.PAA87368@bubba.whistle.com>, Archie Cobbs <archie@whistle.com> 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 <sys/types.h> #include <netinet/in.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200009132358.QAA01085>