| delorie.com/archives/browse.cgi | search |
| From: | Richard Dawe <richdawe AT bigfoot DOT com> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Problem with g++ 2.95.2 & C structures |
| Date: | Sat, 04 Nov 2000 14:36:19 +0000 |
| Organization: | Customer of Energis Squared |
| Lines: | 51 |
| Message-ID: | <3A041EE3.F31E1249@bigfoot.com> |
| NNTP-Posting-Host: | modem-38.arkansas.dialup.pol.co.uk |
| Mime-Version: | 1.0 |
| X-Trace: | news8.svr.pol.co.uk 973348922 2592 62.137.55.38 (4 Nov 2000 14:42:02 GMT) |
| NNTP-Posting-Date: | 4 Nov 2000 14:42:02 GMT |
| X-Complaints-To: | abuse AT theplanet DOT net |
| X-Mailer: | Mozilla 4.51 [en] (X11; I; Linux 2.2.17 i586) |
| X-Accept-Language: | de,fr |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
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
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. :(
TIA, bye,
--
Richard Dawe
[ mailto:richdawe AT bigfoot DOT com | http://www.bigfoot.com/~richdawe/ ]
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |