aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJozef Izso <jozef.izso@gmail.com>2018-04-27 14:25:35 +0200
committerJozef Izso <jozef.izso@gmail.com>2018-05-18 08:59:22 +0200
commitbfa66299a22e1ceb45d89926a4ef3021b41271a5 (patch)
treec0af43a0476f05069fbeaa33bb8f22bcee185d2f
parent0aad7df94445ea0eb8d6dfe3acf07fac9a4e9fa9 (diff)
downloadvcpkg-bfa66299a22e1ceb45d89926a4ef3021b41271a5.tar.gz
vcpkg-bfa66299a22e1ceb45d89926a4ef3021b41271a5.zip
Patch protobuf to fix the compilation error C4146 in wire_format_lite.h
Fixes #3352
-rw-r--r--ports/protobuf/CONTROL2
-rw-r--r--ports/protobuf/portfile.cmake1
-rw-r--r--ports/protobuf/wire_format_lite_h_fix_error_C4146.patch35
3 files changed, 37 insertions, 1 deletions
diff --git a/ports/protobuf/CONTROL b/ports/protobuf/CONTROL
index 8b149b051..5df6f1f69 100644
--- a/ports/protobuf/CONTROL
+++ b/ports/protobuf/CONTROL
@@ -1,5 +1,5 @@
Source: protobuf
-Version: 3.5.1-4
+Version: 3.5.1-5
Description: Protocol Buffers - Google's data interchange format
Feature: zlib
diff --git a/ports/protobuf/portfile.cmake b/ports/protobuf/portfile.cmake
index f96b5240b..87576dea1 100644
--- a/ports/protobuf/portfile.cmake
+++ b/ports/protobuf/portfile.cmake
@@ -20,6 +20,7 @@ vcpkg_apply_patches(
"${CMAKE_CURRENT_LIST_DIR}/export-ParseGeneratorParameter.patch"
"${CMAKE_CURRENT_LIST_DIR}/js-embed.patch"
"${CMAKE_CURRENT_LIST_DIR}/fix-uwp.patch"
+ "${CMAKE_CURRENT_LIST_DIR}/wire_format_lite_h_fix_error_C4146.patch"
)
if(CMAKE_HOST_WIN32)
diff --git a/ports/protobuf/wire_format_lite_h_fix_error_C4146.patch b/ports/protobuf/wire_format_lite_h_fix_error_C4146.patch
new file mode 100644
index 000000000..b56892a22
--- /dev/null
+++ b/ports/protobuf/wire_format_lite_h_fix_error_C4146.patch
@@ -0,0 +1,35 @@
+From 24493eef9395e5b832360e12efabf9c363c9cb15 Mon Sep 17 00:00:00 2001
+From: Rodrigo Hernandez <kwizatz@aeongames.com>
+Date: Mon, 4 Dec 2017 19:04:42 -0600
+Subject: [PATCH] Using binary one's complement to negate an unsigned int
+
+This removes a Visual Studio warning:
+
+warning C4146: unary minus operator applied to unsigned type, result
+still unsigned.
+---
+ src/google/protobuf/wire_format_lite.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h
+index cf614c02a4..361920b8ec 100644
+--- a/src/google/protobuf/wire_format_lite.h
++++ b/src/google/protobuf/wire_format_lite.h
+@@ -860,7 +860,7 @@ inline uint32 WireFormatLite::ZigZagEncode32(int32 n) {
+
+ inline int32 WireFormatLite::ZigZagDecode32(uint32 n) {
+ // Note: Using unsigned types prevent undefined behavior
+- return static_cast<int32>((n >> 1) ^ -(n & 1));
++ return static_cast<int32>((n >> 1) ^ (~(n & 1) + 1));
+ }
+
+ inline uint64 WireFormatLite::ZigZagEncode64(int64 n) {
+@@ -871,7 +871,7 @@ inline uint64 WireFormatLite::ZigZagEncode64(int64 n) {
+
+ inline int64 WireFormatLite::ZigZagDecode64(uint64 n) {
+ // Note: Using unsigned types prevent undefined behavior
+- return static_cast<int64>((n >> 1) ^ -(n & 1));
++ return static_cast<int64>((n >> 1) ^ (~(n & 1) + 1));
+ }
+
+ // String is for UTF-8 text only, but, even so, ReadString() can simply