In article <[EMAIL PROTECTED]>,
Archie Cobbs  <[EMAIL PROTECTED]> wrote:
> This happens on 4.1-RELEASE:
> 
>       $ c++ ... foo.cc
> 
>       /usr/include/netinet/in.h:303: ANSI C++ forbids data member `ip_opts' with 
>same name as enclosing class
>       *** Error code 1
> 
> Any ideas? I tried __BEGIN_DECLS and __END_DECLS but that didn't help.
> I'm not a C++ expert.
> 
>       $ c++ --version
>       $ 2.95.2

I can't duplicate it with this "program":

    #include <sys/types.h>
    #include <netinet/in.h>

I compile it with "cc -c test.cc" and get no errors.  The diagnostic
is valid, but there is a kludge in the compiler to make it work
anyway.  See "src/contrib/gcc.295/cp/decl.c" around line 11515:

            /* 9.2p13 [class.mem] */
            if (declarator == constructor_name (current_class_type)
                /* Divergence from the standard:  In extern "C", we
                   allow non-static data members here, because C does
                   and /usr/include/netinet/in.h uses that.  */
                && (staticp || ! in_system_header))
              cp_pedwarn ("ANSI C++ forbids data member `%D' with same name as 
enclosing class",
                          declarator);

Notice that it is permissive if the declaration is in a "system
header".  This seems to work right, because if I create a local
directory "netinet" containing a copy of "in.h" and add "-I." to the
command line, then I get the diagnostic.

Is this the standard compiler installation, or are you using the ports
version?  If it's the ports version, maybe it has an incorrect notion
of where the system headers are.  I ran my tests using the standard
FreeBSD compiler installation.

John
-- 
  John Polstra                                               [EMAIL PROTECTED]
  John D. Polstra & Co., Inc.                        Seattle, Washington USA
  "Disappointment is a good sign of basic intelligence."  -- Chögyam Trungpa



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to