Skip to contentSkip to conversation

Compiling issue on Visual Studio 2010

Openvpn-devel Fish Wang 5 participants 9 messages Jul 1, 2015 – Jul 3, 2015

lore
Share & tools
lore

Fish Wang

author
#0 lore raw

Hi,

Visual Studio 2010 refuses to compile the latest code on branch release/2.3 because __func__ is not supported. Microsoft supports __FUNCTION__ instead of __func__ in their compiler. VS 2013 complains the same.

The following patch resolves this issue.

src/openvpn/crypto.c +0 -0

index aa93a7b..c4fda84 100644

--- a/src/openvpn/crypto.c

+++ b/src/openvpn/crypto.c

@@ -423,7 +423,7 @@ crypto_adjust_frame_parameters(struct frame *frame,

   frame_add_to_extra_frame (frame, crypto_overhead);

msg(D_MTU_DEBUG, "%s: Adjusting frame parameters for crypto by %zu
bytes",

- __func__, crypto_overhead);

+ CURRENT_FUNCTION, crypto_overhead);

}

/*

src/openvpn/crypto.h +0 -0

index e489827..66704ba 100644

--- a/src/openvpn/crypto.h

+++ b/src/openvpn/crypto.h

@@ -459,6 +459,15 @@ key_ctx_bi_defined(const struct key_ctx_bi* key)

return key->encrypt.cipher || key->encrypt.hmac || key->decrypt.cipher ||
key->decrypt.hmac;

}

+/*

+ * __func__ is not yet supported on Visual Studio 2013

+ */

+

+#ifdef _MSC_VER

+ #define CURRENT_FUNCTION __FUNCTION__

+#else

+ #define CURRENT_FUNCTION __func__

+#endif

#endif /* ENABLE_CRYPTO */

#endif /* CRYPTO_H */

Best,

Fish

#1 lore raw

Am 01.07.15 um 21:47 schrieb Fish Wang:

Quoted 5 lines

Hi,

Quoted 11 lines

Visual Studio 2010 refuses to compile the latest code on branch release/2.3 because __func__ is not supported. Microsoft supports __FUNCTION__ instead of __func__ in their compiler. VS 2013 complains the same.

The following patch resolves this issue.

I would prefer to define _func_ as __FUNCTION__ for 2010 to keep the standard notion and not introduce yet another macro.

Arne

#2 lore raw
In reply to Fish Wang

Hi,

Quoted 3 lines · Fish Wang

Visual Studio 2010 refuses to compile the latest code on branch release/2.3 because __func__ is not supported. Microsoft supports __FUNCTION__ instead of __func__ in their compiler. VS 2013 complains the same.

Thanks for reporting. That's probably my fault, sorry. I think we still support VS, so we'll fix it, but you might want to consider using mingw. That's what the current openvpn developers use for Windows builds (either native, or cross-compile from linux/BSD).

-Steffan

author
#3 lore raw

Hi,

Thank you for the suggestion. I'm sticking with VS since I already have an entire automation environment set up for compiling OpenVPN with Visual Studio. Also I believe Visual Studio provides better security guarantees (like stack canaries, buffer checks etc.).

Best,
Fish

-----Original Message-----
From: Steffan Karger [mailto:[email protected]...]
Sent: Wednesday, July 1, 2015 2:16 PM
To: Fish Wang
Cc: openvpn-devel
Subject: Re: [Openvpn-devel] Compiling issue on Visual Studio 2010

Hi,

Quoted 3 lines · Fish Wang

Visual Studio 2010 refuses to compile the latest code on branch release/2.3 because __func__ is not supported. Microsoft supports __FUNCTION__ instead of __func__ in their compiler. VS 2013 complains the same.

Thanks for reporting. That's probably my fault, sorry. I think we still support VS, so we'll fix it, but you might want to consider using mingw. That's what the current openvpn developers use for Windows builds (either native, or cross-compile from linux/BSD).

-Steffan

#4 lore raw
In reply to Fish Wang
Quoted 1 line · Fish Wang

The following patch resolves this issue.

I think we can do this more simple and robust. See the attached patch. Can you please report if that works for you? Thanks.

-Steffan

From 6e0073163dd3c13a957f8b1760a81a5ef16e65a9 Mon Sep 17 00:00:00 2001
From: Steffan Karger <[email protected]>
Date: Wed, 1 Jul 2015 23:25:56 +0200
Subject: [PATCH] Make __func__ work with Visual Studio too

Because even VS2013 is incapable of doing C99.

---
 src/openvpn/syshead.h | 4 ++++
 1 file changed, 4 insertions(+)
src/openvpn/syshead.h +4 -0
index cf29131..ff0bf41 100644
@@ -45,6 +45,10 @@
 #define srandom srand
 #endif
 
+#ifdef _MSC_VER // Visual Studio
+#define __func__ __FUNCTION__
+#endif
+
 #if defined(__APPLE__)
 #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1070
 #define __APPLE_USE_RFC_3542  1
Signature · 1 line
2.1.4
author
#5 lore raw

Thank you Steffan, the patch works for me.

Best,
Fish

-----Original Message-----
From: Steffan Karger [mailto:[email protected]...]
Sent: Wednesday, July 1, 2015 2:28 PM
To: Fish Wang
Cc: openvpn-devel
Subject: Re: [Openvpn-devel] Compiling issue on Visual Studio 2010

Quoted 1 line · Fish Wang

The following patch resolves this issue.

I think we can do this more simple and robust. See the attached patch. Can you please report if that works for you? Thanks.

-Steffan

#6 lore raw
Quoted 1 line · Fish Wang

Thank you for the suggestion. I'm sticking with VS since I already have an entire automation environment set up for compiling OpenVPN with Visual Studio.

Fair enough.

Quoted 1 line

Also I believe Visual Studio provides better security guarantees (like stack canaries, buffer checks etc.).

Just for reference: those are supported by mingw/gcc too:
-fstack-protector for canaries, -Wl,--nxcompat for DEP, -Wl,--dynamicbase for ASLR.

Quoted 1 line · Fish Wang

Thank you Steffan, the patch works for me.

Great! Thanks for reporting back.

Others: consider my previous mail as a patch submission.

-Steffan

#7 lore raw

Review

Quoted 5 lines
Quoted 2 lines

Also I believe Visual Studio provides better security guarantees (like stack canaries, buffer checks etc.).

Just for reference: those are supported by mingw/gcc too:

(quoted diff) +0 -2
-fstack-protector for canaries, -Wl,--nxcompat for DEP,
-Wl,--dynamicbase for ASLR.

Steffan: so these are the magic incantations that would solve

<https://community.openvpn.net/openvpn/ticket/325>

I'll try those with openvpn-build and see what happens.

Thanks,

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

irc freenode net: mattock
#8 lore raw

[Openvpn-devel] [PATCH applied] Re: Make __func__ work with Visual Studio too

In reply to Steffan Karger

ACK. Your patch has been applied to the master and release/2.3 branch.

commit 9884e20810bda737c7708ff587e09cc0bb8475c7 (master) commit 4188a2dcdc32d36ccbd85396cf40d54d75e2ca3e (release/2.3)

Author: Steffan Karger
Date:   Wed Jul 1 23:25:56 2015 +0200
     Make __func__ work with Visual Studio too

     Signed-off-by: Steffan Karger <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/9859
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering