This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Redefinition of `struct in6_addr'?


> On 4/24/2013 2:12 PM, Corinna Vinschen wrote:
>>
>> On Apr 24 19:53, Samuel Thibault wrote:
>>>
>>> Corinna Vinschen, le Wed 24 Apr 2013 19:51:07 +0200, a écrit :
>>>>>>
>>>>>> /usr/include/cygwin/in6.h:75:8: error: redefinition of ‘struct
>>>>>> in6_addr’
>>>>>>
>>>>>> /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../include/w32api/in6addr.h:17:16:
>>>>>> note: originally defined here
>>>>
>>>>
>>>> Don't know this file but this is a bug in config.h.  struct in6_addr
>>>> is defined in a system header, so it should not be gratuitously defined
>>>> in a project header, especially if the definition collides with the
>>>> right one from the system header.
>>>
>>>
>>> Mmm, but here it's w32api definition vs cygwin definition.
>>
>>
>> Maybe I didn't read it exactly, but the bottom line here is, when
>> building for Cygwin, either use the POSIX network headers (preferredly),
>> or use winsock.h.  Mixing them is not supported.
>
>
> Yeah, though this case is a bit buried, so it's not obvious.  Also the code
> is from 2008, so I expect it has suffered some bit rot over time with
> respect to Cygwin.  In any case, it looks like removing iphlpapi.h from
> sysdep.c solves the problem.


Hey, I got it! It's not cygwin fault...

It's the inclusion of <netinet/in.h> which is done for the first time
in sysdep.h, AFTER the inclusions of the winapi32, where struct
in6_addr is declared. Actually sysdep.c includes its header at the end
of the inclusion list and sysdep.h in its turn has an inclusion for
<netinet/in.h> . The solution is in the following patch:

--- //ioxp/cygwin/usr/src/vpnc-0.5.3/sysdep.c    mer nov 19 21:02:39 2008
+++ //ioxp/cygwin/usr/src/vpnc-0.5.3.1/sysdep.c    mer apr 24 21:53:29 2013
@@ -28,6 +28,7 @@

 #include <sys/socket.h>
 #include <net/if.h>
+#include <netinet/in.h>

 #ifdef __sun__
 #include <ctype.h>
@@ -38,7 +39,6 @@
 #include <sys/sockio.h>
 #include <signal.h>
 #include <stropts.h>
-#include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
 #include <netinet/tcp.h>

Basically the #include <netinet/in.h> has to be moved up a few lines
to get it out of the

#ifdef __sun__
...
#endif

directive. This way the winapi32 headers don't declare struct
in6_addr, I didn't check, but I guess they do so only #ifndef
_CYGWIN_IN6_H, am I right?

For ease of reading, here are the inclusions in sysdep.c as patched by me:


#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include <sys/ioctl.h>
#include <errno.h>

#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>

#ifdef __sun__
#include <ctype.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include <signal.h>
#include <stropts.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#endif

#if defined(__CYGWIN__)
#include <io.h>
#include <w32api/windef.h>
#include <w32api/winbase.h>
#include <w32api/winnt.h>
#include <w32api/winioctl.h>
#include <w32api/iphlpapi.h>
#include <w32api/iptypes.h>
#include <w32api/winreg.h>
#include <sys/cygwin.h>
#endif

#if defined(__DragonFly__)
#include <net/tun/if_tun.h>
#elif defined(__linux__)
#include <linux/if_tun.h>
#elif defined(__APPLE__)
/* no header for tun */
#elif defined(__CYGWIN__)
#include "tap-win32.h"
#else
#include <net/if_tun.h>
#endif

#include "sysdep.h"

#if !defined(HAVE_VASPRINTF) || !defined(HAVE_ASPRINTF) || !defined(HAVE_ERROR)
#include <stdarg.h>
#endif

#if defined(__sun__)
extern char **environ;
static int ip_fd = -1, muxid;
#endif

OK, so that's it, vpnc-0.5.3 will then compile like a charm. Ah, by
the way, you must have perl installed and run ./enum2debug.pl isakmp.h
 >vpnc-debug.c 2>vpnc-debug.h right before to make.

Thanks to all for attention, and once again sorry if I dared to post
in the wrong mailing list. You must be patient I'm just a newcomer...
Didn't mean to bother!!

:-)

BR,
Max

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]