diff --git a/configure.ac b/configure.ac
index 1813cc57..1d9ceb4b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -897,7 +897,8 @@
                 src/versioninfo.rc
                 src/gpgme.pc
                 src/gpgme-glib.pc
-                src/gpgme.h)
+                src/gpgme.h
+                lang/cpp/src/data.h)
 AC_CONFIG_FILES(src/gpgme-config, chmod +x src/gpgme-config)
 AC_CONFIG_FILES(lang/cpp/Makefile lang/cpp/src/Makefile)
 AC_CONFIG_FILES(lang/cpp/tests/Makefile)
diff --git a/lang/cpp/src/Makefile.am b/lang/cpp/src/Makefile.am
index 1e6bdc28..ccfb16b0 100644
--- a/lang/cpp/src/Makefile.am
+++ b/lang/cpp/src/Makefile.am
@@ -20,7 +20,7 @@
 # 02111-1307, USA
 
 EXTRA_DIST = GpgmeppConfig.cmake.in.in GpgmeppConfigVersion.cmake.in \
-             gpgmepp_version.h.in GpgmeppConfig-w32.cmake.in.in
+             gpgmepp_version.h.in data.h.in GpgmeppConfig-w32.cmake.in.in
 
 lib_LTLIBRARIES = libgpgmepp.la
 
@@ -38,7 +38,7 @@ main_sources = \
     vfsmountresult.cpp configuration.cpp tofuinfo.cpp swdbresult.cpp
 
 gpgmepp_headers = \
-    configuration.h context.h data.h decryptionresult.h \
+    configuration.h context.h decryptionresult.h \
     defaultassuantransaction.h editinteractor.h encryptionresult.h \
     engineinfo.h error.h eventloopinteractor.h exception.h global.h \
     gpgadduserideditinteractor.h gpgagentgetinfoassuantransaction.h \
@@ -60,7 +60,7 @@ interface_headers= \
 gpgmeppincludedir = $(includedir)/gpgme++
 gpgmeppinclude_HEADERS = $(gpgmepp_headers)
 nobase_gpgmeppinclude_HEADERS = $(interface_headers)
-nodist_gpgmeppinclude_HEADERS = gpgmepp_version.h
+nodist_gpgmeppinclude_HEADERS = gpgmepp_version.h data.h
 
 libgpgmepp_la_SOURCES = $(main_sources) $(gpgmepp_headers) context_vanilla.cpp \
                         $(interface_headers) $(private_gpgmepp_headers)
@@ -106,4 +106,4 @@ install-data-local: install-cmake-files
 uninstall-local: uninstall-cmake-files
 
 CLEANFILES = GpgmeppConfig.cmake GpgmeppConfigVersion.cmake \
-             gpgmepp_version.h GpgmeppConfig.cmake.in
+             gpgmepp_version.h data.h GpgmeppConfig.cmake.in
diff --git a/lang/cpp/src/data.cpp b/lang/cpp/src/data.cpp
index 2782aa79..1da0df52 100644
--- a/lang/cpp/src/data.cpp
+++ b/lang/cpp/src/data.cpp
@@ -217,17 +217,17 @@ GpgME::Error GpgME::Data::setFileName(const char *name)
     return Error(gpgme_data_set_file_name(d->data, name));
 }
 
-ssize_t GpgME::Data::read(void *buffer, size_t length)
+gpgme_ssize_t GpgME::Data::read(void *buffer, size_t length)
 {
     return gpgme_data_read(d->data, buffer, length);
 }
 
-ssize_t GpgME::Data::write(const void *buffer, size_t length)
+gpgme_ssize_t GpgME::Data::write(const void *buffer, size_t length)
 {
     return gpgme_data_write(d->data, buffer, length);
 }
 
-off_t GpgME::Data::seek(off_t offset, int whence)
+gpgme_off_t GpgME::Data::seek(gpgme_off_t offset, int whence)
 {
     return gpgme_data_seek(d->data, offset, whence);
 }
diff --git a/lang/cpp/src/data.h b/lang/cpp/src/data.h.in
similarity index 93%
rename from lang/cpp/src/data.h
rename to lang/cpp/src/data.h.in
index df8607e7..1c909ef8 100644
--- a/lang/cpp/src/data.h
+++ b/lang/cpp/src/data.h.in
@@ -26,11 +26,13 @@
 #include "global.h"
 #include "key.h"
 
-#include <sys/types.h> // for size_t, off_t
 #include <cstdio> // FILE
 #include <algorithm>
 #include <memory>
 
+/* System specific typedefs.  */
+@INSERT__TYPEDEFS_FOR_GPGME_H@
+
 namespace GpgME
 {
 
@@ -106,9 +108,9 @@ public:
     char *fileName() const;
     Error setFileName(const char *name);
 
-    ssize_t read(void *buffer, size_t length);
-    ssize_t write(const void *buffer, size_t length);
-    off_t seek(off_t offset, int whence);
+    gpgme_ssize_t read(void *buffer, size_t length);
+    gpgme_ssize_t write(const void *buffer, size_t length);
+    gpgme_off_t seek(gpgme_off_t offset, int whence);
 
     /* Convenience function to do a seek (0, SEEK_SET).  */
     Error rewind();
diff --git a/lang/qt/src/Makefile.am b/lang/qt/src/Makefile.am
index 32251424..60f18b10 100644
--- a/lang/qt/src/Makefile.am
+++ b/lang/qt/src/Makefile.am
@@ -217,7 +217,7 @@ nodist_qgpgmeinclude_HEADERS = qgpgme_version.h
 
 libqgpgme_la_SOURCES = $(qgpgme_sources) $(qgpgme_headers) $(private_qgpgme_headers)
 
-AM_CPPFLAGS = -I$(top_srcdir)/lang/cpp/src -I$(top_builddir)/src \
+AM_CPPFLAGS = -I$(top_srcdir)/lang/cpp/src -I$(top_builddir)/lang/cpp/src -I$(top_builddir)/src \
               @GPGME_QT_CFLAGS@ @GPG_ERROR_CFLAGS@ @LIBASSUAN_CFLAGS@ \
               -DBUILDING_QGPGME
 
diff --git a/lang/qt/tests/Makefile.am b/lang/qt/tests/Makefile.am
index bfe77ad5..7856a4f6 100644
--- a/lang/qt/tests/Makefile.am
+++ b/lang/qt/tests/Makefile.am
@@ -39,7 +39,7 @@ LDADD = ../../cpp/src/libgpgmepp.la ../src/libqgpgme.la \
         ../../../src/libgpgme.la @GPGME_QT_LIBS@ @GPG_ERROR_LIBS@ \
         @GPGME_QTTEST_LIBS@ -lstdc++
 
-AM_CPPFLAGS = -I$(top_srcdir)/lang/cpp/src -I$(top_builddir)/src \
+AM_CPPFLAGS = -I$(top_srcdir)/lang/cpp/src -I$(top_builddir)/lang/cpp/src -I$(top_builddir)/src \
               @GPG_ERROR_CFLAGS@ @GPGME_QT_CFLAGS@ @GPG_ERROR_CFLAGS@ \
               @LIBASSUAN_CFLAGS@ @GPGME_QTTEST_CFLAGS@ -DBUILDING_QGPGME \
               -I$(top_srcdir)/lang/qt/src \
