Am 03.12.2010 16:22, schrieb Samuli Seppänen: > Hi, > > I've managed to extend the Python build system so that it now tries to > build the Windows service wrapper, "openvpnserv.exe", after building > "openvpn.exe". However, the Visual Studio 2008 C compiler gives these > errors: > > openvpnserv.c(87): error C2010: '.' : unexpected in macro formal > parameter list > openvpnserv.c(101): error C2010: '.' : unexpected in macro formal > parameter list > > The offending lines with context (in beta2.2 branch) are these: > > #define mysnprintf(out, args...) \ > ... > #define MSG(flags, args...) \ > > The C2010 error is described (very briefly) here: > > <http://msdn.microsoft.com/en-us/library/64sxk83h.aspx> > > Any ideas how to fix this issue?
Hi Samuli, What you see in the offending lines is GCC's old syntax for variadic macros. If Visual Studio 2008 understands C99 sufficiently, you could #ifdef around this and use the current form in the code for GCC compilers, and the C99 form for others. See http://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html#Variadic-Macros for an explanation. Please try the attached patch - note I haven't been able to test this beyond making sure it compiles on GCC 4.3. HTH. Best regards Matthias
From c54a7fa98f4c8d567c26ce3bd6d80f3a68173bd8 Mon Sep 17 00:00:00 2001 From: Matthias Andree <matthias.and...@gmx.de> List-Post: openvpn-devel@lists.sourceforge.net Date: Sat, 4 Dec 2010 03:51:11 +0100 Subject: [PATCH] Change variadic macros to C99 style. Breaks compatibility with GCC versions before 3.0, in an attempt to fix compilation on Visual Studio 2008. Compiles on GCC 4.3, but untested on Visual Studio 2008. --- service-win32/openvpnserv.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/service-win32/openvpnserv.c b/service-win32/openvpnserv.c index 6c9ff1e..07374e2 100755 --- a/service-win32/openvpnserv.c +++ b/service-win32/openvpnserv.c @@ -84,9 +84,9 @@ static HANDLE exit_event = NULL; #define CLEAR(x) memset(&(x), 0, sizeof(x)) /* snprintf with guaranteed null termination */ -#define mysnprintf(out, args...) \ +#define mysnprintf(out, ...) \ { \ - snprintf (out, sizeof(out), args); \ + snprintf (out, sizeof(out), __VA_ARGS__); \ out [sizeof (out) - 1] = '\0'; \ } @@ -98,10 +98,10 @@ static HANDLE exit_event = NULL; #define M_ERR (MSG_FLAGS_ERROR) // error /* write error to event log */ -#define MSG(flags, args...) \ +#define MSG(flags, ...) \ { \ char x_msg[256]; \ - mysnprintf (x_msg, args); \ + mysnprintf (x_msg, __VA_ARGS__); \ AddToMessageLog ((flags), x_msg); \ } -- 1.7.3.2.438.g94fdb6
pgpol4xNcgjNd.pgp
Description: PGP signature