IP with C++ problem

Joel Sherrill joel.sherrill at OARcorp.com
Fri Sep 14 12:41:59 UTC 2001


Chris Johns wrote:
> 
> "Andrew N. Maximov" wrote:
> >
> > Hello rtems-users,
> >
> > There is a problem while using network in C++.
> > When I attempt to compile this example
> > /*****************************************/
> > #include <sys/types.h>
> > #include <sys/socket.h>
> > #include <sys/sockio.h>
> > #include <net/if.h>
> > #include <netinet/in.h>
> > /*****************************************/
> > gcc produces an error:
> > netinet/in.h:282: ANSI C++ forbids data member `ip_opts' with same name as enclosing class
> >
> > The problem is in the netinet/in.h file.
> > The structure ip_opts is declared as
> >
> > struct ip_opts {
> >         struct  in_addr ip_dst;         /* first hop, 0 w/o src rt */
> >         char    ip_opts[40];            /* actually variable in size */
> > };
> >
> > The name and the member of structure
> > have an identical name "ip_opts".
> >
> > Whether this problem will be being solved?
> >
> 
> You have found a "feature" in gcc where this error is suppressed for
> system includes. This is why C++ works fine on FreeBSD. Ralf provided an
> excellent solution to this problem back on 19 Dec 2000 under a mail
> thread called "RTEMS + g++ + #include <netinet/in.h>". I suggest you
> search the archive for the thread. Here is the solution Ralf provided :
> 
>  > For now, all RTEMS headers (=RTEMS system headers) have to be
>  > installed to $(prefix)/<BSP>/lib/include.
>  > I.e. -isystem $(prefix)/<BSP>/lib/include or -B$(prefix)/<BSP>/lib/
>  > has to be _prepended_ to the compile command if using gcc.
>  > If using 3rd party compilers, you will probably have a hard time
>  > getting this working at all.

So how is gcc invoked in this case?  The "normal" invocation 
includes a "-B... -qrtems" which meets this requirement.

> --
>  Chris Johns, cjohns @ cybertec.com.au

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985



More information about the users mailing list