www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/11/05/09:25:24

Date: Sun, 5 Nov 2000 16:23:17 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
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.SUN.3.91.1001105161943.29647B-100000@is>
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:

> 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.

- Raw text -


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