Mail Archives: djgpp/2000/11/05/09:25:24
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 -