IP with C++ problem
Rosimildo da Silva
rdasilva at connecttel.com
Fri Sep 14 12:50:57 UTC 2001
From: "Andrew N. Maximov" <amaximus at mail.ru>
To: "rtems-users" <rtems-users at OARcorp.com>
Sent: Friday, September 14, 2001 3:31 AM
Subject: IP with C++ problem
> 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?
>
In C++ these "hacks" are illegal.
Many of the *BSD header files are broken regarding C++,
and you need to add round them:
extern "C"
{
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include <net/if.h>
#include <netinet/in.h>
};
or fix the offending file, and send a patch to Joel. :-)
Take Care, Rosimildo.
More information about the users
mailing list