Re: [Openvpn-devel] [PATCH] Fix win32 building with C99 mode
Hi, On Sun, Sep 18, 2016 at 10:15:56PM +0200, Gert Doering wrote: > On Sun, Sep 18, 2016 at 10:20:16AM -0400, Selva Nair wrote: > > Yeah, to me that only confirms my feeling that #ifdef WIN32 is not > > reliable. Much better to use _WIN32 which appears to be defined by all (?) > > C compilers that support windows and doesn't require any particular header > > to be included. > > http://nadeausoftware.com/articles/2012/01/c_c_tip_how_ > > use_compiler_predefined_macros_detect_operating_system# > > WindowsCygwinnonPOSIXandMinGW [..] trac #746 gert -- USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany g...@greenie.muc.de fax: +49-89-35655025g...@net.informatik.tu-muenchen.de signature.asc Description: PGP signature -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH] Fix win32 building with C99 mode
Hi, On Sun, Sep 18, 2016 at 10:20:16AM -0400, Selva Nair wrote: > Yeah, to me that only confirms my feeling that #ifdef WIN32 is not > reliable. Much better to use _WIN32 which appears to be defined by all (?) > C compilers that support windows and doesn't require any particular header > to be included. > http://nadeausoftware.com/articles/2012/01/c_c_tip_how_ > use_compiler_predefined_macros_detect_operating_system# > WindowsCygwinnonPOSIXandMinGW > > Anyway, right now the priority being un-break building on windows, your v2 > looks good. I'll test it and report back. Thanks for testing and ACKing. Merged. I think I'll open a trac ticket for the next step, so it isn't lost - we intend to do a major round of formatting cleanup before 2.4, and changing WIN32 to _WIN32 in the process would nicely fit :-) gert -- USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany g...@greenie.muc.de fax: +49-89-35655025g...@net.informatik.tu-muenchen.de signature.asc Description: PGP signature -- ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH] Fix win32 building with C99 mode
On Sun, Sep 18, 2016 at 2:59 AM, Gert Doering wrote: > Ah. Here we go... trying to redefine WIN32 at the end of syshead.h > shows what is happening: > > In file included from /usr/share/mingw-w64/include/windef.h:8:0, > from /usr/share/mingw-w64/include/windows.h:69, > from /usr/share/mingw-w64/include/winsock2.h:23, > from ../../src/compat/compat.h:29, > from syshead.h:28, > > so compat.h is pulling it via > > #ifdef HAVE_WINSOCK2_H > #include > #endif > > whee... > Yeah, to me that only confirms my feeling that #ifdef WIN32 is not reliable. Much better to use _WIN32 which appears to be defined by all (?) C compilers that support windows and doesn't require any particular header to be included. http://nadeausoftware.com/articles/2012/01/c_c_tip_how_ use_compiler_predefined_macros_detect_operating_system# WindowsCygwinnonPOSIXandMinGW Anyway, right now the priority being un-break building on windows, your v2 looks good. I'll test it and report back. Thanks, Selva -- ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH] Fix win32 building with C99 mode
we already run openvpn/openvpn-build in travis. build only is not complicated. there are minor issues with 14.04 mingw gcc, which is too old for openvpn master. I'll make patch after I will resolve it. 2016-09-17 18:58 GMT+05:00 Gert Doering : > Hi, > On Sat, Sep 17, 2016 at 06:40:00PM +0500, ?? wrote: > > Should we add mingw compiler to travis-ci matrix? > > If travis can do mingw builds, that would be good. > > But it is complicated. > > gert > -- > USENET is *not* the non-clickable part of WWW! >// > www.muc.de/~gert/ > Gert Doering - Munich, Germany > g...@greenie.muc.de > fax: +49-89-35655025g...@net.informatik.tu- > muenchen.de > -- ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH] Fix win32 building with C99 mode
Hi, On Sat, Sep 17, 2016 at 07:11:56PM -0400, Selva Nair wrote: > On Sat, Sep 17, 2016 at 9:20 AM, Gert Doering wrote: > > > In -std=c99 mode, WIN32 is not defined to be "1" anymore, but just > > "#define WIN32" - so the "#if WIN32" breaks, needs to be "#ifdef WIN32" > > Indeed... > > To depend on the compiler or system headers to define WIN32 was not a great > idea anyway. Using _WIN32 or __WIN32 is probably more reliable. Or we > should define WIN32 in config.h. With std=c99, it seems WIN32 gets defined > by chance through some header pulled-in by syshead.h -- not something one > can rely on. Heiko says that "WIN32 is what everybody is testing for on Windows", so that seems to be an official API define... With c99, on mingw, the #define WIN32 comes from "minwindef.h", which is included from "windef.h", which is included from "windows.h" -- but I wonder how we ever include that in the first place, given this code in syshead.h #ifdef WIN32 #include #include #define sleep(x) Sleep((x)*1000) #define random rand #define srandom srand #endif ... so maybe it is actually *never* set, even with my patch, and we just do not know it's breaking because it's not linking...? Ah. Here we go... trying to redefine WIN32 at the end of syshead.h shows what is happening: In file included from /usr/share/mingw-w64/include/windef.h:8:0, from /usr/share/mingw-w64/include/windows.h:69, from /usr/share/mingw-w64/include/winsock2.h:23, from ../../src/compat/compat.h:29, from syshead.h:28, so compat.h is pulling it via #ifdef HAVE_WINSOCK2_H #include #endif whee... > Compiler-defined macros with std=c99: > $ x86_64-w64-mingw32-gcc -std=c99 -E -dM - #define _WIN32 1 > #define __WIN32 1 > #define __WIN32__ 1 > > As for a quick fix, the patch takes care of misc.c, but there is an issue > with block_dns.c as well. It does not include the required config.h and > syshead.h at the top before #ifdef WIN32, so now the whole file gets > skipped -- mea culpa, mea culpa... > > I think we can just remove #ifdef WIN32 from block_dns.c (its compiled only > on Windows), and add config.h and syshead.h headers at the top. Then we > also need -I$(top_srcdir)/src/compat in src/openvpnsev/Makefile.am as > compat.h is included by syshead.h. Do you have time to cook up & test such a patch? Then I'll go and focus a bit more on my windows testing environment in the meantime, and merge the patch later today... thanks, gert -- USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany g...@greenie.muc.de fax: +49-89-35655025g...@net.informatik.tu-muenchen.de signature.asc Description: PGP signature -- ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH] Fix win32 building with C99 mode
Hi, On Sat, Sep 17, 2016 at 9:20 AM, Gert Doering wrote: > In -std=c99 mode, WIN32 is not defined to be "1" anymore, but just > "#define WIN32" - so the "#if WIN32" breaks, needs to be "#ifdef WIN32" > Indeed... To depend on the compiler or system headers to define WIN32 was not a great idea anyway. Using _WIN32 or __WIN32 is probably more reliable. Or we should define WIN32 in config.h. With std=c99, it seems WIN32 gets defined by chance through some header pulled-in by syshead.h -- not something one can rely on. Compiler-defined macros with std=c99: $ x86_64-w64-mingw32-gcc -std=c99 -E -dM - -- ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH] Fix win32 building with C99 mode
Hi, On Sat, Sep 17, 2016 at 06:40:00PM +0500, ?? wrote: > Should we add mingw compiler to travis-ci matrix? If travis can do mingw builds, that would be good. But it is complicated. gert -- USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany g...@greenie.muc.de fax: +49-89-35655025g...@net.informatik.tu-muenchen.de signature.asc Description: PGP signature -- ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH] Fix win32 building with C99 mode
Should we add mingw compiler to travis-ci matrix? 17 сент. 2016 г. 6:34 PM пользователь "Gert Doering" написал: In -std=c99 mode, WIN32 is not defined to be "1" anymore, but just "#define WIN32" - so the "#if WIN32" breaks, needs to be "#ifdef WIN32" Signed-off-by: Gert Doering --- src/openvpn/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c index 0991d79..2982cd0 100644 --- a/src/openvpn/misc.c +++ b/src/openvpn/misc.c @@ -977,7 +977,7 @@ hostname_randomize(const char *hostname, struct gc_arena *gc) const char * gen_path (const char *directory, const char *filename, struct gc_arena *gc) { -#if WIN32 +#ifdef WIN32 const int CC_PATH_RESERVED = CC_LESS_THAN|CC_GREATER_THAN|CC_COLON| CC_DOUBLE_QUOTE|CC_SLASH|CC_BACKSLASH|CC_PIPE|CC_QUESTION_ MARK|CC_ASTERISK; #else -- 1.9.1 -- ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel -- ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
[Openvpn-devel] [PATCH] Fix win32 building with C99 mode
In -std=c99 mode, WIN32 is not defined to be "1" anymore, but just "#define WIN32" - so the "#if WIN32" breaks, needs to be "#ifdef WIN32" Signed-off-by: Gert Doering --- src/openvpn/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c index 0991d79..2982cd0 100644 --- a/src/openvpn/misc.c +++ b/src/openvpn/misc.c @@ -977,7 +977,7 @@ hostname_randomize(const char *hostname, struct gc_arena *gc) const char * gen_path (const char *directory, const char *filename, struct gc_arena *gc) { -#if WIN32 +#ifdef WIN32 const int CC_PATH_RESERVED = CC_LESS_THAN|CC_GREATER_THAN|CC_COLON| CC_DOUBLE_QUOTE|CC_SLASH|CC_BACKSLASH|CC_PIPE|CC_QUESTION_MARK|CC_ASTERISK; #else -- 1.9.1 -- ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel