delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/11/06/02:28:32

Date: Mon, 6 Nov 2000 09:16:32 +0200 (WET)
From: Andris Pavenis <pavenis AT lanet DOT lv>
To: Richard Dawe <richdawe AT bigfoot DOT com>
cc: DJGPP newsgroup <djgpp AT delorie DOT com>
Subject: Re: Problem with g++ 2.95.2 & C structures
In-Reply-To: <3A05690C.C6B42417@bigfoot.com>
Message-ID: <Pine.A41.4.05.10011060904470.37262-100000@ieva06.lanet.lv>
MIME-Version: 1.0
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


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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019