[vlc-devel] [PATCH 14/19] contrib: protobuf: fix building with ming32

Steve Lhomme robux4 at videolabs.io
Wed Jun 14 14:02:03 CEST 2017


Some Windows common defines are used in enums or as parameters and gcc replace
them incorrectly in the code.
---
 contrib/src/protobuf/rules.mak           |  3 +++
 contrib/src/protobuf/win32-defines.patch | 40 ++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 contrib/src/protobuf/win32-defines.patch

diff --git a/contrib/src/protobuf/rules.mak b/contrib/src/protobuf/rules.mak
index 693773337e..5c15157e33 100644
--- a/contrib/src/protobuf/rules.mak
+++ b/contrib/src/protobuf/rules.mak
@@ -22,6 +22,9 @@ protobuf: protobuf-$(PROTOBUF_VERSION)-cpp.tar.gz .sum-protobuf
 	$(UNPACK)
 	mv protobuf-3.1.0 protobuf-3.1.0-cpp
 	$(APPLY) $(SRC)/protobuf/dont-build-protoc.patch
+ifdef HAVE_WIN32
+	$(APPLY) $(SRC)/protobuf/win32-defines.patch
+endif
 	$(MOVE)
 
 .protobuf: protobuf
diff --git a/contrib/src/protobuf/win32-defines.patch b/contrib/src/protobuf/win32-defines.patch
new file mode 100644
index 0000000000..ed345958d8
--- /dev/null
+++ b/contrib/src/protobuf/win32-defines.patch
@@ -0,0 +1,40 @@
+--- protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc	2016-09-24 03:27:21.000000000 +0200
++++ protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc.win32	2017-06-13 13:34:31.526928100 +0200
+@@ -581,6 +581,10 @@ bool IsWellKnownMessage(const FileDescri
+   return !descriptor->name().compare(0, 16, kGoogleProtobufPrefix);
+ }
+ 
++#undef STRICT
++#undef VERIFY
++#undef NONE
++
+ enum Utf8CheckMode {
+   STRICT = 0,  // Parsing will fail if non UTF-8 data is in string fields.
+   VERIFY = 1,  // Only log an error but parsing will succeed.
+--- protobuf/src/google/protobuf/stubs/logging.h	2017-06-13 14:54:35.906519900 +0200
++++ protobuf/src/google/protobuf/stubs/logging.h.win32	2017-06-13 14:55:11.686157900 +0200
+@@ -114,6 +114,11 @@ inline bool IsOk(bool status) { return s
+ 
+ }  // namespace internal
+ 
++#undef ERROR
++#undef FATAL
++#undef WARNING
++#undef INFO
++
+ // Undef everything in case we're being mixed with some other Google library
+ // which already defined them itself.  Presumably all Google libraries will
+ // support the same syntax for these so it should not be a big deal if they
+--- protobuf/src/google/protobuf/stubs/time.h	2017-06-13 14:56:26.446109700 +0200
++++ protobuf/src/google/protobuf/stubs/time.h.win32	2017-06-13 12:56:54.403057100 +0200
+@@ -32,6 +32,10 @@
+ 
+ #include <google/protobuf/stubs/common.h>
+ 
++#ifdef GetCurrentTime
++#undef GetCurrentTime
++#endif
++
+ namespace google {
+ namespace protobuf {
+ namespace internal {
-- 
2.12.1



More information about the vlc-devel mailing list