Date: Sun, 5 Nov 2000 16:23:17 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Richard Dawe cc: DJGPP newsgroup Subject: Re: Problem with g++ 2.95.2 & C structures In-Reply-To: <3A05690C.C6B42417@bigfoot.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Sun, 5 Nov 2000, Richard Dawe wrote: > extern "C" > { > struct pointless { > int pointless; > }; > } > > int main (void) > { > struct pointless no_point; > > return(1); > } > > If I try making this, I get the following problem: > > bash-2.04$ make test-struct > gpp test-struct.cc -o test-struct > test-struct.cc:5: ANSI C++ forbids data member `pointless' with same name > as enclosing class > make.exe: *** [test-struct] Error 1 > > Why doesn't this work? Surely the extern statement should inform the > compiler it's in C code, not C++? I think ``extern "C"'' only means that the names of the external identifiers inside the extern "C" block should have C bindings instead of C++ bindings; that is, it disables the C++-style mangling. But it does NOT change the language rules, because the code is still compiled as C++. > I'd appreciate help with this problem, because the libsocket header > netinet/in.h has a structure called ip_opts with a field called ip_opts. > This stops C++ programs using libsocket from building. :( Is ip_opts used by other in.h implementations? If not, you could easily rename it.