Re: Redefinition of `struct in6_addr'?

2013-04-24 Thread Max Balduino
On Wed, Apr 24, 2013 at 6:15 PM, Max Balduino
>> On Apr 24 17:34, Max Balduino wrote:
>>> Dear all,
>>>
>>> Looks like there's something wrong here:
>>>
>>> userwinemt@ioxp /usr/src/vpnc-0.5.2
>>> $ make install
>>> LC_ALL=C perl -w ./enum2debug.pl isakmp.h >vpnc-debug.c 2>vpnc-debug.h
>>> gcc -O3 -g -W -Wall -Wmissing-declarations -Wwrite-strings
>>> -DVERSION=\"0.5.2\"   -c -o sysdep.o sysdep.c
>>> In file included from /usr/include/cygwin/in.h:267,
>>>  from /usr/include/netinet/in.h:14,
>>>  from sysdep.h:23,
>>>  from sysdep.c:71:
>>> /usr/include/cygwin/in6.h:76: error: redefinition of `struct in6_addr'
>>>
>>> I'm compiling vpnc-0.5.2 on a fresh cygwin environment, just
>>> downloaded from stable distribution. I'm using gcc version 3.4.4
>>> (cygming special, gdc 0.12, using dmd 0.125). I've googled for it and
>>> found a post reading "Problems with latest cygwin + latest sources"
>>> that claims for the same error.
>>>
>>> Anybody has seen this before or has a quick workaround, please?
>>
>> - You are not using the right mailing list for this kind of question.
>>   Use the cygwin AT cygwin DOT com list instead.
>>
>> - You're using an old and outdated compiler.  Install the gcc4 package
>>   instead.
>>
>> - You're missing to paste the entire error message.  Gcc usually prints
>>   where the clashing definition is defined, too.  But maybe that's just
>>   in gcc 4.x.
>>
>> - Last but not least, a simple testcase would be helpful.
>>
>> Without that I can only guess: The file includes winsock.h because
>> it wrongly treats Cygwin as Windows environment.  Don't do that.
>>
>>
>> Corinna
>>
>> --
>> Corinna Vinschen  Please, send mails regarding Cygwin to
>> Cygwin Maintainer cygwin AT cygwin DOT com
>> Red Hat
>
> First of all thanks a *LOT* for your quick answer!
>
> OK, sorry for having used the wrong mail-list! I re-compiled under gcc
> version 4.5.3 (GCC) getting same result.
>
> I'm trying to compile an app, that's why I was posting on cygwin-apps
> AT cygwin DOT com. You can find it at
> http://www.unix-ag.uni-kl.de/~massar/vpnc/ it's a cisco-compatible vpn
> client.
>
> I'm not sure what did you mean "a simple testcase would be helpful"?
> If it's the piece of code, then Here it is:
>
> from sysdep.h:
>
> 
> #ifndef __SYSDEP_H__
> #define __SYSDEP_H__
>
> /*
>  * Different systems define different macros.
>  * For vpnc, this list should be used as
>  * reference:
>  *
>  * __linux__
>  * __NetBSD__
>  * __OpenBSD__
>  * __FreeBSD__
>  * __DragonFly__
>  * __APPLE__  Darwin / MacOS X
>  * __sun__SunOS / Solaris
>  * __CYGWIN__
>  * __SKYOS__
>  *
>  */
>
> #include 
> #include 
> #include 
>
> #if !defined(__CYGWIN__)
> #include 
> #include 
> #include 
> #endif
>
> #include "config.h"
>
> int tun_open(char *dev, enum if_mode_enum mode);
> int tun_close(int fd, char *dev);
> int tun_write(int fd, unsigned char *buf, int len);
> int tun_read(int fd, unsigned char *buf, int len);
> int tun_get_hwaddr(int fd, char *dev, uint8_t *hwaddr);
>
> /***/
> #if defined(__linux__) || defined(__GLIBC__)
> #include 
>
> #define HAVE_VASPRINTF 1
> #define HAVE_ASPRINTF  1
> #define HAVE_ERROR 1
> #define HAVE_GETLINE   1
> #define HAVE_UNSETENV  1
> #define HAVE_SETENV1
> #endif
> ...
> 
>
> As of the complete gcc error dump, here it also is:
>
> userwinemt@ioxp /usr/src/vpnc-0.5.3
> $ make install
> gcc -O3 -g -W -Wall -Wmissing-declarations -Wwrite-strings
> -DVERSION=\"0.5.3\"   -c -o sysdep.o sysdep.c
> In file included from /usr/include/cygwin/in.h:267:0,
>  from /usr/include/netinet/in.h:14,
>  from sysdep.h:23,
>  from sysdep.c:71:
> /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
> In file included from sysdep.h:31:0,
>  from sysdep.c:71:
> config.h:131:83: warning: ‘struct debug_strings’ declared inside parameter 
> list
> config.h:131:83: warning: its scope is only this definition or
> declaration, which is probab

Re: Redefinition of `struct in6_addr'?

2013-04-24 Thread Max Balduino
> 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  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
 . The solution is in the following patch:

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

 #include 
 #include 
+#include 

 #ifdef __sun__
 #include 
@@ -38,7 +39,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 

Basically the #include  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 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 

#ifdef __sun__
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#endif

#if defined(__CYGWIN__)
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#endif

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

#include "sysdep.h"

#if !defined(HAVE_VASPRINTF) || !defined(HAVE_ASPRINTF) || !defined(HAVE_ERROR)
#include 
#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