IP with C++ problem

Andrew N. Maximov amaximus at mail.ru
Mon Sep 17 14:05:20 UTC 2001


Hello Joel,

Friday, September 14, 2001, 4:41:59 PM, you wrote:

JS> 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.

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

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


Thanks for answers.
I specified option "–B" in command line and solved my problem.
But I've not found a "mail thread called "RTEMS + g++ + #include <netinet/in.h>"
Why mail-lists are not stored in the mbox format ?
The html format is not convenient for search.
-- 
Best regards,
 Andrew ICQ:101436920             mailto:amaximus at mail.ru





More information about the users mailing list