Fixes to Visual Studio 2008 build errors
cover Fixes to Visual Studio 2008 build errors
These patches fix a large number of build errors in "master" branch as reported on Trac ticket #137.
PATCH 1/4 Fixed a number of fatal build errors on Visual Studio 2008
Partially fixes ticket #137
--- helper.c | 12 ++++++------ socket.c | 4 ++++ win/config.h.in | 2 +- win32.h | 2 ++ 4 files changed, 13 insertions(+), 7 deletions(-)
helper.c +6 -6
@@ -143,6 +143,12 @@ helper_client_server (struct options *o)#if P2MP #if P2MP_SERVER +/* +* Get tun/tap/null device type +*/ +const int dev =dev_type_enum (o->dev, o->dev_type); +const int topology = o->topology; +/* * * HELPER DIRECTIVE for IPv6
@@ -220,12 +226,6 @@ helper_client_server (struct options *o)* push "route-gateway 10.8.0.1" */ -/* -* Get tun/tap/null device type -*/ -const int dev =dev_type_enum (o->dev, o->dev_type); -const int topology = o->topology; -if (o->server_defined) {int netbits =-2 ;
socket.c +4 -0
@@ -3156,6 +3156,8 @@ link_socket_write_udp_posix_sendmsg (struct link_socket *sock,* inet_ntop() and inet_pton() wrap-implementations using * WSAAddressToString() and WSAStringToAddress() functions */ + +/* const char * inet_ntop(int af, const void *src, char *dst, socklen_t size) {
@@ -3204,6 +3206,8 @@ inet_pton(int af, const char *src, void *dst)return 0; } +*/ +int socket_recv_queue (struct link_socket *sock,int maxsize) {
win/config.h.in +1 -1
@@ -275,7 +275,7 @@ typedef unsigned long in_addr_t; #define inline __inline /* type to use in place of socklen_t if not defined */ -#define socklen_t unsigned int +/*#define socklen_t unsigned int*/ #ifndef __MINGW32__ /* 32-bit unsigned type */
win32.h +2 -0
@@ -272,8 +272,10 @@ char *get_win_sys_path (void);/* call self in a subprocess */ void fork_to_self (const char *cmdline); +#ifdef _MSV_VERconst char *inet_ntop (int af,const void *src,char *dst,socklen_t size);int inet_pton (int af,const char *src,void *st); +#endif /* Find temporary directory */ const char *win_get_tempdir ();
Signature · 1 line
1.6.3.3
Gert Doering
NAKRe: [Openvpn-devel] [PATCH 1/4] Fixed a number of fatal build errors on Visual Studio 2008
Hi,
Quoted 5 lines · Samuli Seppänen
Partially fixes ticket #137
Signed-off-by Gert Doering <[email protected]...>Signed-off-by Samuli Seppänen <[email protected]...>Tested-by Samuli Seppänen <[email protected]...>
NAK, something went wrong here.
Quoted 18 lines
helper.c +6
-0@@ -143,6 +143,12 @@ helper_client_server (struct options *o)#if P2MP #if P2MP_SERVER +/* +* Get tun/tap/null device type +*/ +const int dev =dev_type_enum (o->dev, o->dev_type); +const int topology = o->topology; +/* * * HELPER DIRECTIVE for IPv6 @@ -220,12 +226,6 @@ helper_client_server (struct options *o)* push "route-gateway 10.8.0.1" */
helper.c helper_client_server (struct options *o) · line 231
Quoted 10 lines
helper.c +0
-6-/* -* Get tun/tap/null device type -*/ -const int dev =dev_type_enum (o->dev, o->dev_type); -const int topology = o->topology; -if (o->server_defined) {int netbits =-2 ;
This is OK.
Quoted 14 lines
socket.c +2
-0@@ -3156,6 +3156,8 @@ link_socket_write_udp_posix_sendmsg (struct link_socket *sock,* inet_ntop() and inet_pton() wrap-implementations using * WSAAddressToString() and WSAStringToAddress() functions */ + +/* const char * inet_ntop(int af, const void *src, char *dst, socklen_t size) {
socket.c inet_pton(int af, const char *src, void *dst) · line 3213
Quoted 8 lines
socket.c +2
-0@@ -3204,6 +3206,8 @@ inet_pton(int af, const char *src, void *dst)return 0; } +*/ +int socket_recv_queue (struct link_socket *sock,int maxsize) {
This is not. Our local implementations of inet_ntop and inet_pton are needed for msys/mingw and conflict with MS VS, so they need to be there, but conditional on _MSC_VER. So this should be:
#ifndef _MSC_VER
...
#endif
win/config.h.in typedef unsigned long in_addr_t; · line 281
Quoted 13 lines
win/config.h.in +1
-1@@ -275,7 +275,7 @@ typedef unsigned long in_addr_t; #define inline __inline /* type to use in place of socklen_t if not defined */ -#define socklen_t unsigned int +/*#define socklen_t unsigned int*/ #ifndef __MINGW32__ /* 32-bit unsigned type */
This needs to be tested whether it still works with mingw/msys - I have my doubts. So this change also needs to be conditional
#ifndef _MSC_VER
#define socklen_t unsigned int
#endif
(or vice versa, "#ifdef __MINGW32__").
win32.h char *get_win_sys_path (void); · line 278
Quoted 12 lines
win32.h +2
-0@@ -272,8 +272,10 @@ char *get_win_sys_path (void);/* call self in a subprocess */ void fork_to_self (const char *cmdline); +#ifdef _MSV_VERconst char *inet_ntop (int af,const void *src,char *dst,socklen_t size);int inet_pton (int af,const char *src,void *st); +#endif
NAK, this needs to be "#ifndef _MSC_VER"
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...PATCH 1/1 Fix problems with fixes to socket.c and win32.h
--- socket.c | 5 ++--- win32.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-)
socket.c +2 -3
@@ -3157,7 +3157,7 @@ link_socket_write_udp_posix_sendmsg (struct link_socket *sock,* WSAAddressToString() and WSAStringToAddress() functions */ -/* +#ifndef _MSC_VERconst char *inet_ntop (int af,const void *src,char *dst,socklen_t size) {
@@ -3205,8 +3205,7 @@ inet_pton(int af, const char *src, void *dst) }return 0 ; } - -*/ +#endif int socket_recv_queue (struct link_socket *sock,int maxsize)
win32.h +1 -1
@@ -272,7 +272,7 @@ char *get_win_sys_path (void);/* call self in a subprocess */ void fork_to_self (const char *cmdline); -#ifdef _MSV_VER +#ifndef _MSC_VERconst char *inet_ntop (int af,const void *src,char *dst,socklen_t size);int inet_pton (int af,const char *src,void *st);#endif
Signature · 1 line
1.6.3.3
Re: [Openvpn-devel] [PATCH] Fix problems with fixes to socket.c and win32.h
Hi,
Quoted 13 lines · Samuli Seppänen
Signed-off-by Gert Doering <[email protected]...>Tested-by Samuli Seppänen <[email protected]...>Signed-off-by Samuli Seppänen <[email protected]...>--- socket.c | 5 ++--- win32.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-)socket.c +0
-0
socket.c link_socket_write_udp_posix_sendmsg (struct link_socket *sock, · line 3162
Quoted 7 lines
socket.c +1
-1@@ -3157,7 +3157,7 @@ link_socket_write_udp_posix_sendmsg (struct link_socket *sock,* WSAAddressToString() and WSAStringToAddress() functions */ -/* +#ifndef _MSC_VERconst char *inet_ntop (int af,const void *src,char *dst,socklen_t size)
...
ACK!
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Re: [Openvpn-devel] [PATCH 1/4] Fixed a number of fatal build errors on Visual Studio 2008
In reply to Gert DoeringQuoted 19 lines
Quoted 7 lines
win/config.h.in +0
-0win/config.h.in typedef unsigned long in_addr_t; · line 281
Quoted 8 lines
win/config.h.in +1
-1@@ -275,7 +275,7 @@ typedef unsigned long in_addr_t; #define inline __inline /* type to use in place of socklen_t if not defined */ -#define socklen_t unsigned int +/*#define socklen_t unsigned int*/ #ifndef __MINGW32__ /* 32-bit unsigned type */This needs to be tested whether it still works with mingw/msys - I have my doubts. So this change also needs to be conditional
Quoted 6 lines
#ifndef
_MSC_VER
#definesocklen_tunsigned int
#endif(or vice versa, "#ifdef
__MINGW32__").
As discussed on the IRC, win/config.h.in is only used by the new build system and will not affect mingw/msys. The rest of the problems (hopefully) fixed in the patch I sent a few minutes ago.
Signature · 5 lines
Samuli Seppänen Community Manager OpenVPN Technologies, Inc irc freenode net: mattock
PATCH 2/4 Fix Microsoft Visual Studio incompatibility in plugin.c
In reply to Samuli SeppänenFrom: David Sommerseth <[email protected]...>
MS Visual Studio don't like to have struct members named in the variable declaration. Without this fix, Visual Studio is not able to compile the new v3 plug-in API.
--- plugin.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
plugin.c +10 -10
@@ -299,9 +299,9 @@ plugin_open_item (struct plugin *p,* Call the plugin initialization */ if (p->open3) { -struct openvpn_plugin_args_open_in args = { .type_mask = p->plugin_type_mask, - .argv = o->argv, - .envp = envp }; +struct openvpn_plugin_args_open_in args = { p->plugin_type_mask, + (const char **const ) o->argv, + (const char **const ) envp };struct openvpn_plugin_args_open_return retargs;CLEAR (retargs);
@@ -367,13 +367,13 @@ plugin_call_item (const struct plugin *p,* Call the plugin work function */ if (p->func3) { -struct openvpn_plugin_args_func_in args = { .type = type, - .argv = (const char **) a.argv, - .envp = envp, - .handle = p->plugin_handle, - .per_client_context = per_client_context, - .current_cert_depth = (current_cert ? certdepth :-1 ), - .current_cert = current_cert }; +struct openvpn_plugin_args_func_in args = { type, + (const char **const ) a.argv, + (const char **const ) envp, + p->plugin_handle, + per_client_context, + (current_cert ? certdepth :-1 ), + current_cert };struct openvpn_plugin_args_func_return retargs;CLEAR (retargs);
Signature · 1 line
1.6.3.3
Re: [Openvpn-devel] [PATCH 2/4] Fix Microsoft Visual Studio incompatibility in plugin.c
Hi,
Quoted 3 lines · Samuli Seppänen
MS Visual Studio don't like to have struct members named in the variable declaration. Without this fix, Visual Studio is not able to compile the new v3 plug-in API.
ACK. Looks reasonable (what I've checked is: make sure that the variables in question are in the order that the structure expect it - which the compiler can't sort out for you if it doesn't understand the new format of specifying struct inits).
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...PATCH 3/4 Fix a Visual Studio 2008 build error in tun.c
In reply to Samuli SeppänenFrom: Samuli Seppanen <[email protected]...>
Partially fixes ticket #137
--- tun.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tun.c +1 -1
@@ -572,7 +572,7 @@ init_tun_post (struct tuntap *tt,#endif } -#if defined(TARGET_WIN32 ) || \ +#if defined(WIN32 ) || \ defined(TARGET_DARWIN ) || defined(TARGET_NETBSD ) || defined(TARGET_OPENBSD )/* some of the platforms will auto-add a "network route" pointing
Signature · 1 line
1.6.3.3
Re: [Openvpn-devel] [PATCH 3/4] Fix a Visual Studio 2008 build error in tun.c
Hi,
tun.c init_tun_post (struct tuntap *tt, · line 576
Quoted 11 lines · Samuli Seppänen
tun.c +1
-1@@ -572,7 +572,7 @@ init_tun_post (struct tuntap *tt,#endif } -#if defined(TARGET_WIN32 ) || \ +#if defined(WIN32 ) || \ defined(TARGET_DARWIN ) || defined(TARGET_NETBSD ) || defined(TARGET_OPENBSD )
ACK. TARGET_WIN32 is not defined in MS VS (no autoconf), and the rest of the code uses WIN32 everywhere - and as this is the single place where TARGET_WIN32 is used, changing it to WIN32 is the way of least pain.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...PATCH 4/4 Fix a Visual Studio 2008 build error in options.c
In reply to Samuli SeppänenFrom: Samuli Seppanen <[email protected]...>
Partially fixes Trac ticket #137
--- syshead.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
syshead.h +1 -0
@@ -342,6 +342,7 @@#ifdef WIN32 #include <iphlpapi.h> +#include <NtDDNdis.h> #include <wininet.h> /* The following two headers are needed of USE_PF_INET6 */ #include <winsock2.h>
Signature · 1 line
1.6.3.3
PATCH 1/1 Fix a Visual Studio 2008 build issue in socket.c
In reply to Samuli Seppänen--- socket.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
socket.c +2 -1
@@ -647,8 +647,9 @@ update_remote (const char* host,if (host && addr) {struct sockaddr_in6 sin6; +int success;CLEAR (sin6); - int success = getaddr6 ( + success = getaddr6 ( sf2gaf(GETADDR_RESOLVE|GETADDR_UPDATE_MANAGEMENT_STATE, sockflags), host, 1,
Signature · 1 line
1.6.3.3
Re: [Openvpn-devel] [PATCH] Fix a Visual Studio 2008 build issue in socket.c
Hi,
Quoted 11 lines · Samuli Seppänen
Signed-off-by Gert Doering <[email protected]...>Signed-off-by Samuli Seppänen <[email protected]...>--- socket.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)socket.c +0
-0
socket.c update_remote (const char* host, · line 653
Quoted 8 lines
socket.c +2
-1@@ -647,8 +647,9 @@ update_remote (const char* host,if (host && addr) {struct sockaddr_in6 sin6; +int success;CLEAR (sin6); - int success = getaddr6 ( + success = getaddr6 ( sf2gaf(GETADDR_RESOLVE|GETADDR_UPDATE_MANAGEMENT_STATE, sockflags),
Well, ACK, obviously :-)
This is the usual windows compiler problem that doesn't permit variable declarations "right in the middle of the code".
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...