Date: Mon, 6 Nov 2000 09:16:32 +0200 (WET) From: Andris Pavenis 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: > Hello. > > I'm having a problem with structures and C++. Here is a program that > demonstrates the problem: > > 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 Seems that this is problem of only gcc-2.95.X gcc-2.97 20001103 compiles this without errors both with and without extern "C" around definition of structure (I tested this under Linux). The same about egcs-1.1.2 > > Why doesn't this work? Surely the extern statement should inform the > compiler it's in C code, not C++? > > Here's the gpp version: > > bash-2.04$ gpp -v > Reading specs from c:/djgpp/lib/gcc-lib/djgpp/2.952/specs > gcc version 2.95.2 19991024 (release) > > FYI on Linux this works fine with egcs: > > iolanthe:/usr/include =] g++ -v > Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs > gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) > > 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. :( > As this problem is no more in current development versions of gcc-2.97 I think it's very unlikely it will be fixed in gcc-2.95.X. Andris