Mail Archives: djgpp/2000/11/06/02:28:32
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 -