aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-10-06 14:05:48 +0200
committerJay Berkenbilt <ejb@ql.org>2022-10-06 14:40:08 +0200
commit5c5b4e640e2df248192ff7aa518fb0d345884a33 (patch)
tree1f2a331ee8f0aa8cba685b0192d093238a919e7e
parentdb6598b449f4edbb69a581ecc8bc6791e24ad3ea (diff)
downloadqpdf-5c5b4e640e2df248192ff7aa518fb0d345884a33.tar.zst
Be more conservative about QPDF_DLL_CLASS with mingw (fixes #799)
* Define it even though previous experiments have shown it to be unnecessary since it seems like it may be necessary after all * Add QPDF_DLL_CLASS to QPDFObjectHelper and QPDFDocumentHelper in case there's some future unknown reason why someone may want to have them and/or in case it helps with the weird QPDFNameTreeObjectHelper problem.
-rw-r--r--README-maintainer6
-rw-r--r--include/qpdf/DLL.h9
-rw-r--r--include/qpdf/QPDFDocumentHelper.hh4
-rw-r--r--include/qpdf/QPDFObjectHelper.hh4
-rw-r--r--libqpdf/CMakeLists.txt2
-rw-r--r--libqpdf/QPDFDocumentHelper.cc7
-rw-r--r--libqpdf/QPDFObjectHelper.cc7
7 files changed, 31 insertions, 8 deletions
diff --git a/README-maintainer b/README-maintainer
index 545612c4..3658a347 100644
--- a/README-maintainer
+++ b/README-maintainer
@@ -179,9 +179,11 @@ CODING RULES
the shared object boundary (or "shared library boundary" -- we may
use either term in comments and documentation). In particular,
anything new derived from Pipeline or InputSource should be marked
- with QPDF_DLL_CLASS, but we don't need to do it for QPDFObjectHelper
+ with QPDF_DLL_CLASS. We shouldn't need to do it for QPDFObjectHelper
or QPDFDocumentHelper subclasses since there's no reason to use
- dynamic_cast with those.
+ dynamic_cast with those, but doing it anyway may help with some
+ strange cases for mingw or with some code generators that may
+ systematically do this for other reasons.
IMPORTANT NOTE ABOUT QPDF_DLL_CLASS: On mingw, the vtable for a
class with some virtual methods and no pure virtual methods seems
diff --git a/include/qpdf/DLL.h b/include/qpdf/DLL.h
index 14cc5bae..257486b0 100644
--- a/include/qpdf/DLL.h
+++ b/include/qpdf/DLL.h
@@ -42,14 +42,16 @@
# define QPDF_DLL
# endif
# define QPDF_DLL_PRIVATE
-# define QPDF_DLL_CLASS
#elif defined __GNUC__
# define QPDF_DLL __attribute__((visibility("default")))
# define QPDF_DLL_PRIVATE __attribute__((visibility("hidden")))
-# define QPDF_DLL_CLASS QPDF_DLL
#else
# define QPDF_DLL
# define QPDF_DLL_PRIVATE
+#endif
+#ifdef __GNUC__
+# define QPDF_DLL_CLASS QPDF_DLL
+#else
# define QPDF_DLL_CLASS
#endif
@@ -87,6 +89,9 @@ for a more in-depth discussion.
multi-platform and building both static and shared libraries that
use the same headers, so we don't bother.
+ * If we don't export base classes with mingw, the vtables don't end
+ up in the DLL.
+
* On Linux (and other similar systems):
* Common compilers such as gcc and clang export all symbols into the
diff --git a/include/qpdf/QPDFDocumentHelper.hh b/include/qpdf/QPDFDocumentHelper.hh
index 55fe3c9c..e78788ab 100644
--- a/include/qpdf/QPDFDocumentHelper.hh
+++ b/include/qpdf/QPDFDocumentHelper.hh
@@ -36,7 +36,7 @@
// introduced to allow creation of higher level helper functions
// without polluting the public interface of QPDF.
-class QPDFDocumentHelper
+class QPDF_DLL_CLASS QPDFDocumentHelper
{
public:
QPDF_DLL
@@ -45,7 +45,7 @@ class QPDFDocumentHelper
{
}
QPDF_DLL
- virtual ~QPDFDocumentHelper() = default;
+ virtual ~QPDFDocumentHelper();
QPDF_DLL
QPDF&
getQPDF()
diff --git a/include/qpdf/QPDFObjectHelper.hh b/include/qpdf/QPDFObjectHelper.hh
index db3876ec..7f0f21ca 100644
--- a/include/qpdf/QPDFObjectHelper.hh
+++ b/include/qpdf/QPDFObjectHelper.hh
@@ -37,7 +37,7 @@
// introduced to allow creation of higher level helper functions
// without polluting the public interface of QPDFObjectHandle.
-class QPDFObjectHelper
+class QPDF_DLL_CLASS QPDFObjectHelper
{
public:
QPDF_DLL
@@ -46,7 +46,7 @@ class QPDFObjectHelper
{
}
QPDF_DLL
- virtual ~QPDFObjectHelper() = default;
+ virtual ~QPDFObjectHelper();
QPDF_DLL
QPDFObjectHandle
getObjectHandle()
diff --git a/libqpdf/CMakeLists.txt b/libqpdf/CMakeLists.txt
index 7053e205..5e3a628e 100644
--- a/libqpdf/CMakeLists.txt
+++ b/libqpdf/CMakeLists.txt
@@ -59,6 +59,7 @@ set(libqpdf_SOURCES
QPDFAnnotationObjectHelper.cc
QPDFArgParser.cc
QPDFCryptoProvider.cc
+ QPDFDocumentHelper.cc
QPDFEFStreamObjectHelper.cc
QPDFEmbeddedFileDocumentHelper.cc
QPDFExc.cc
@@ -74,6 +75,7 @@ set(libqpdf_SOURCES
QPDFNumberTreeObjectHelper.cc
QPDFObject.cc
QPDFObjectHandle.cc
+ QPDFObjectHelper.cc
QPDFObjGen.cc
QPDFOutlineDocumentHelper.cc
QPDFOutlineObjectHelper.cc
diff --git a/libqpdf/QPDFDocumentHelper.cc b/libqpdf/QPDFDocumentHelper.cc
new file mode 100644
index 00000000..ad23e6f8
--- /dev/null
+++ b/libqpdf/QPDFDocumentHelper.cc
@@ -0,0 +1,7 @@
+#include <qpdf/QPDFDocumentHelper.hh>
+
+QPDFDocumentHelper::~QPDFDocumentHelper()
+{
+ // Must be explicit and not inline -- see QPDF_DLL_CLASS in
+ // README-maintainer
+}
diff --git a/libqpdf/QPDFObjectHelper.cc b/libqpdf/QPDFObjectHelper.cc
new file mode 100644
index 00000000..3696dc03
--- /dev/null
+++ b/libqpdf/QPDFObjectHelper.cc
@@ -0,0 +1,7 @@
+#include <qpdf/QPDFObjectHelper.hh>
+
+QPDFObjectHelper::~QPDFObjectHelper()
+{
+ // Must be explicit and not inline -- see QPDF_DLL_CLASS in
+ // README-maintainer
+}