[PATCH 5/5] port: first cut at building cpp binding natively on W32

thb at libreoffice.org thb at libreoffice.org
Tue Jan 30 15:18:10 CET 2018


From: Thorsten Behrens <Thorsten.Behrens at CIB.de>

Signed-off-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
---
 lang/cpp/src/callbacks.cpp             |  2 ++
 lang/cpp/src/data.h                    |  5 +++++
 lang/cpp/src/editinteractor.cpp        |  6 ++++--
 lang/cpp/src/gpgmepp_export.h          | 12 ++++++++----
 lang/cpp/src/interfaces/dataprovider.h |  5 +++++
 lang/cpp/src/key.cpp                   |  6 ++++++
 lang/cpp/src/key.h                     |  1 -
 lang/qt/src/qgpgme_export.h            | 12 ++++++++----
 8 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/lang/cpp/src/callbacks.cpp b/lang/cpp/src/callbacks.cpp
index f7692a03..50983943 100644
--- a/lang/cpp/src/callbacks.cpp
+++ b/lang/cpp/src/callbacks.cpp
@@ -40,7 +40,9 @@
 #include <cassert>
 #include <cerrno>
 #include <cstring>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 
 static inline gpgme_error_t make_err_from_syserror()
diff --git a/lang/cpp/src/data.h b/lang/cpp/src/data.h
index cc7906fb..7b171f12 100644
--- a/lang/cpp/src/data.h
+++ b/lang/cpp/src/data.h
@@ -31,6 +31,11 @@
 #include <algorithm>
 #include <memory>
 
+#ifdef _MSC_VER
+#  include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+#endif
+
 namespace GpgME
 {
 
diff --git a/lang/cpp/src/editinteractor.cpp b/lang/cpp/src/editinteractor.cpp
index 3e294889..518fe7ea 100644
--- a/lang/cpp/src/editinteractor.cpp
+++ b/lang/cpp/src/editinteractor.cpp
@@ -32,9 +32,11 @@
 
 #include <gpgme.h>
 
-#ifdef _WIN32
+#ifdef _MSC_VER
 # include <io.h>
-#include <windows.h>
+# include <windows.h>
+# include <BaseTsd.h>
+  typedef SSIZE_T ssize_t;
 #else
 # include <unistd.h>
 #endif
diff --git a/lang/cpp/src/gpgmepp_export.h b/lang/cpp/src/gpgmepp_export.h
index 0e5302f2..ac5a0076 100644
--- a/lang/cpp/src/gpgmepp_export.h
+++ b/lang/cpp/src/gpgmepp_export.h
@@ -30,14 +30,14 @@
 #  ifndef GPGMEPP_EXPORT
 #    ifdef BUILDING_GPGMEPP
         /* We are building this library */
-#      ifdef WIN32
+#      ifdef _MSC_VER
 #       define GPGMEPP_EXPORT __declspec(dllexport)
 #      else
 #       define GPGMEPP_EXPORT __attribute__((visibility("default")))
 #      endif
 #    else
         /* We are using this library */
-#      ifdef WIN32
+#      ifdef _MSC_VER
 #       define GPGMEPP_EXPORT __declspec(dllimport)
 #      else
 #       define GPGMEPP_EXPORT __attribute__((visibility("default")))
@@ -46,7 +46,7 @@
 #  endif
 
 #  ifndef GPGMEPP_NO_EXPORT
-#    ifdef WIN32
+#    ifdef _MSC_VER
 #     define GPGMEPP_NO_EXPORT
 #    else
 #     define GPGMEPP_NO_EXPORT __attribute__((visibility("hidden")))
@@ -55,7 +55,11 @@
 #endif
 
 #ifndef GPGMEPP_DEPRECATED
-#  define GPGMEPP_DEPRECATED __attribute__ ((__deprecated__))
+#  ifdef _MSC_VER
+#    define GPGMEPP_DEPRECATED __declspec(deprecated("deprecated"))
+#  else
+#    define GPGMEPP_DEPRECATED __attribute__ ((__deprecated__))
+#  endif
 #endif
 
 #ifndef GPGMEPP_DEPRECATED_EXPORT
diff --git a/lang/cpp/src/interfaces/dataprovider.h b/lang/cpp/src/interfaces/dataprovider.h
index c8f387d6..348ff6d7 100644
--- a/lang/cpp/src/interfaces/dataprovider.h
+++ b/lang/cpp/src/interfaces/dataprovider.h
@@ -31,6 +31,11 @@
 
 #include <gpg-error.h>
 
+#ifdef _MSC_VER
+#  include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+#endif
+
 namespace GpgME
 {
 
diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 66fdea96..d14ad0a0 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -33,10 +33,16 @@
 #include <gpgme.h>
 
 #include <string.h>
+#if HAVE_STRINGS_H
 #include <strings.h>
+#endif
 #include <istream>
 #include <iterator>
 
+#ifdef _MSC_VER
+#  define strcasecmp _stricmp
+#endif
+
 const GpgME::Key::Null GpgME::Key::null;
 
 namespace GpgME
diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h
index 829bd266..360dfca8 100644
--- a/lang/cpp/src/key.h
+++ b/lang/cpp/src/key.h
@@ -30,7 +30,6 @@
 #include "gpgmefw.h"
 
 #include <memory>
-#include <sys/time.h>
 
 #include <vector>
 #include <algorithm>
diff --git a/lang/qt/src/qgpgme_export.h b/lang/qt/src/qgpgme_export.h
index 72927fe3..9298f2f0 100644
--- a/lang/qt/src/qgpgme_export.h
+++ b/lang/qt/src/qgpgme_export.h
@@ -40,14 +40,14 @@
 #  ifndef QGPGME_EXPORT
 #    ifdef BUILDING_QGPGME
         /* We are building this library */
-#      ifdef WIN32
+#      ifdef _WIN32
 #       define QGPGME_EXPORT __declspec(dllexport)
 #      else
 #       define QGPGME_EXPORT __attribute__((visibility("default")))
 #      endif
 #    else
         /* We are using this library */
-#      ifdef WIN32
+#      ifdef _WIN32
 #       define QGPGME_EXPORT __declspec(dllimport)
 #      else
 #       define QGPGME_EXPORT __attribute__((visibility("default")))
@@ -56,7 +56,7 @@
 #  endif
 
 #  ifndef QGPGME_NO_EXPORT
-#    ifdef WIN32
+#    ifdef _WIN32
 #     define QGPGME_NO_EXPORT
 #    else
 #     define QGPGME_NO_EXPORT __attribute__((visibility("hidden")))
@@ -65,7 +65,11 @@
 #endif
 
 #ifndef QGPGME_DEPRECATED
-#  define QGPGME_DEPRECATED __attribute__ ((__deprecated__))
+#  ifdef _MSC_VER
+#    define QGPGME_DEPRECATED __declspec(deprecated("deprecated"))
+#  else
+#    define QGPGME_DEPRECATED __attribute__ ((__deprecated__))
+#  endif
 #endif
 
 #ifndef QGPGME_DEPRECATED_EXPORT
-- 
2.13.6




More information about the Gnupg-devel mailing list