Skip to contentSkip to conversation

Error C2010 in openvpnserv.c during VS2008 build

Openvpn-devel Applied Samuli Seppänen 3 participants 6 messages Dec 3, 2010 – Dec 4, 2010

lore
Share & tools
lore
#0 lore raw

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?

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
#1 lore raw

Am 03.12.2010 16:22, schrieb Samuli Seppänen:

Quoted 18 lines

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...) \
Quoted 5 lines

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 <[email protected]...>
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(-)
service-win32/openvpnserv.c +4 -4
index 6c9ff1e..07374e2 100755
@@ -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); \
         }
 
Signature · 1 line
1.7.3.2.438.g94fdb6
#2 lore raw

Am 04.12.2010 03:55, schrieb Matthias Andree:

Quoted 31 lines

Am 03.12.2010 16:22, schrieb Samuli Seppänen:

Quoted 18 lines

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...) \
Quoted 5 lines

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.

Quoted 5 lines

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.

Huh, something broke my GnuPG signature. It is OK in my "Sent" folder.

Note that the patch shouldn't be committed with the original message, but is meant for testing. If it keeps working with whatever is normally used to build the Windows release of OpenVPN (GCC, and Visual Studio), feel free to commit with an updated comment though.

Signature · 1 line
Matthias Andree
#3 lore raw
In reply to Matthias Andree

Matthias Andree ha scritto:

Quoted 36 lines

Am 03.12.2010 16:22, schrieb Samuli Seppänen:

Quoted 18 lines

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...) \
Quoted 6 lines

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.

Quoted 8 lines

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

Hi Matthias,

Your patch fixes the issue.

Thanks!

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
#4 lore raw

Am 04.12.2010 11:37, schrieb Samuli Seppänen:

Quoted 3 lines

Hi Matthias,

Your patch fixes the issue.

Hi Samuli,

then please use the attached /updated/ patch (same code, different log entry). It fixes VS2008, and breaks compatibility with GCC before 3.0.

For the records, it was discussed on IRC with David Sommerseth and yourself on 2010-12-04 around 11:08 UTC that we deem it unnecessary to keep GCC < 3.0 compatibility for this new Windows-only code.

Best

Signature · 1 line
Matthias Andree

From 0374c641d4086dfea91bd64c22bb5280bbddf346 Mon Sep 17 00:00:00 2001
From: Matthias Andree <[email protected]...>
Date: Sat, 4 Dec 2010 03:51:11 +0100
Subject: [PATCH] Change variadic macros to C99 style.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The macros used GCC's pre-C99 syntax, which could not be compiled with Microsoft Visual Studio 2008.

Note this breaks compatibility with GCC versions before 3.0, which is deemed safe in a discussion on IRC with David Sommerseth and Samuli Sepp��nen on #openvpn-devel (RHEL 3 uses GCC 3.2 already).

Compiled tested on VS2008 by Samuli, on Cygwin GCC 3.4 and GCC 4.3 by myself.

---
 service-win32/openvpnserv.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
service-win32/openvpnserv.c +4 -4
index 6c9ff1e..07374e2 100755
@@ -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); \
         }
 
Signature · 1 line
1.7.3.2.438.g94fdb6
Acked-by Applied
#5 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/12/10 12:17, Matthias Andree wrote:

| Am 04.12.2010 11:37, schrieb Samuli Seppänen:
|> Hi Matthias,
|>
|> Your patch fixes the issue.
|
| Hi Samuli,
|
| then please use the attached /updated/ patch (same code, different log entry).
| It fixes VS2008, and breaks compatibility with GCC before 3.0.
|
| For the records, it was discussed on IRC with David Sommerseth and yourself on
| 2010-12-04 around 11:08 UTC that we deem it unnecessary to keep GCC<  3.0
| compatibility for this new Windows-only code.
|
| From: Matthias Andree <[email protected]...>
| Date: Sat, 4 Dec 2010 03:51:11 +0100
| Subject: [PATCH] Change variadic macros to C99 style.
| MIME-Version: 1.0
| Content-Type: text/plain; charset=UTF-8
| Content-Transfer-Encoding: 8bit
|
| The macros used GCC's pre-C99 syntax, which could not be compiled with
| Microsoft Visual Studio 2008.
|
| Note this breaks compatibility with GCC versions before 3.0, which is
| deemed safe in a discussion on IRC with David Sommerseth and Samuli
| Seppänen on #openvpn-devel (RHEL 3 uses GCC 3.2 already).
|
| Compiled tested on VS2008 by Samuli, on Cygwin GCC 3.4 and GCC 4.3 by myself.
|
| Signed-off-by: Matthias Andree <[email protected]...>

Applied to bugfix2.1 (commit 9469168e3abb09bd78297208a917ee4d9c025041) and merged into allmerged and beta2.2.

In addition, gcc-2.95.3 is the last 2.xx release which was released in March 2001 [1]. To be very honest, I have no issues that we force users to upgrade such ancient compilers.

As this will also only impact environments who compiles the openvpnserv command as a Windows binary - either natively on a Windows box or cross-compiling with such old compilers. This program is also not used by non-Windows plattforms at all. Thus the impact on old compilers is minimal.

And if there are users still using the old 2.95 gcc compiler. Consider to upgrade soon. OpenVPN will not support such old environments forever. So far we have occasionally checked if OpenVPN is compilable and works on RHEL4. RHEL4 has EOL for the regular cycle in February 2012 [2], with an extended support cycle until February 2015. At that point we might move on to something newer as the oldest supported environment.

Kind regards,

David Sommerseth

[1] <http://gcc.gnu.org/releases.html>
[2] <https://access.redhat.com/support/policy/updates/errata/>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkz6KZsACgkQDC186MBRfrqywwCghbs5sAeMuTljcd4ZvBSWVRNM f+sAn28BSl3CRUAFJhSYTYYT4829etdX
=uIIS
-----END PGP SIGNATURE-----