Commit 5c5b4e640e2df248192ff7aa518fb0d345884a33

Authored by Jay Berkenbilt
1 parent db6598b4

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.
README-maintainer
@@ -179,9 +179,11 @@ CODING RULES @@ -179,9 +179,11 @@ CODING RULES
179 the shared object boundary (or "shared library boundary" -- we may 179 the shared object boundary (or "shared library boundary" -- we may
180 use either term in comments and documentation). In particular, 180 use either term in comments and documentation). In particular,
181 anything new derived from Pipeline or InputSource should be marked 181 anything new derived from Pipeline or InputSource should be marked
182 - with QPDF_DLL_CLASS, but we don't need to do it for QPDFObjectHelper 182 + with QPDF_DLL_CLASS. We shouldn't need to do it for QPDFObjectHelper
183 or QPDFDocumentHelper subclasses since there's no reason to use 183 or QPDFDocumentHelper subclasses since there's no reason to use
184 - dynamic_cast with those. 184 + dynamic_cast with those, but doing it anyway may help with some
  185 + strange cases for mingw or with some code generators that may
  186 + systematically do this for other reasons.
185 187
186 IMPORTANT NOTE ABOUT QPDF_DLL_CLASS: On mingw, the vtable for a 188 IMPORTANT NOTE ABOUT QPDF_DLL_CLASS: On mingw, the vtable for a
187 class with some virtual methods and no pure virtual methods seems 189 class with some virtual methods and no pure virtual methods seems
include/qpdf/DLL.h
@@ -42,14 +42,16 @@ @@ -42,14 +42,16 @@
42 # define QPDF_DLL 42 # define QPDF_DLL
43 # endif 43 # endif
44 # define QPDF_DLL_PRIVATE 44 # define QPDF_DLL_PRIVATE
45 -# define QPDF_DLL_CLASS  
46 #elif defined __GNUC__ 45 #elif defined __GNUC__
47 # define QPDF_DLL __attribute__((visibility("default"))) 46 # define QPDF_DLL __attribute__((visibility("default")))
48 # define QPDF_DLL_PRIVATE __attribute__((visibility("hidden"))) 47 # define QPDF_DLL_PRIVATE __attribute__((visibility("hidden")))
49 -# define QPDF_DLL_CLASS QPDF_DLL  
50 #else 48 #else
51 # define QPDF_DLL 49 # define QPDF_DLL
52 # define QPDF_DLL_PRIVATE 50 # define QPDF_DLL_PRIVATE
  51 +#endif
  52 +#ifdef __GNUC__
  53 +# define QPDF_DLL_CLASS QPDF_DLL
  54 +#else
53 # define QPDF_DLL_CLASS 55 # define QPDF_DLL_CLASS
54 #endif 56 #endif
55 57
@@ -87,6 +89,9 @@ for a more in-depth discussion. @@ -87,6 +89,9 @@ for a more in-depth discussion.
87 multi-platform and building both static and shared libraries that 89 multi-platform and building both static and shared libraries that
88 use the same headers, so we don't bother. 90 use the same headers, so we don't bother.
89 91
  92 + * If we don't export base classes with mingw, the vtables don't end
  93 + up in the DLL.
  94 +
90 * On Linux (and other similar systems): 95 * On Linux (and other similar systems):
91 96
92 * Common compilers such as gcc and clang export all symbols into the 97 * Common compilers such as gcc and clang export all symbols into the
include/qpdf/QPDFDocumentHelper.hh
@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 // introduced to allow creation of higher level helper functions 36 // introduced to allow creation of higher level helper functions
37 // without polluting the public interface of QPDF. 37 // without polluting the public interface of QPDF.
38 38
39 -class QPDFDocumentHelper 39 +class QPDF_DLL_CLASS QPDFDocumentHelper
40 { 40 {
41 public: 41 public:
42 QPDF_DLL 42 QPDF_DLL
@@ -45,7 +45,7 @@ class QPDFDocumentHelper @@ -45,7 +45,7 @@ class QPDFDocumentHelper
45 { 45 {
46 } 46 }
47 QPDF_DLL 47 QPDF_DLL
48 - virtual ~QPDFDocumentHelper() = default; 48 + virtual ~QPDFDocumentHelper();
49 QPDF_DLL 49 QPDF_DLL
50 QPDF& 50 QPDF&
51 getQPDF() 51 getQPDF()
include/qpdf/QPDFObjectHelper.hh
@@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
37 // introduced to allow creation of higher level helper functions 37 // introduced to allow creation of higher level helper functions
38 // without polluting the public interface of QPDFObjectHandle. 38 // without polluting the public interface of QPDFObjectHandle.
39 39
40 -class QPDFObjectHelper 40 +class QPDF_DLL_CLASS QPDFObjectHelper
41 { 41 {
42 public: 42 public:
43 QPDF_DLL 43 QPDF_DLL
@@ -46,7 +46,7 @@ class QPDFObjectHelper @@ -46,7 +46,7 @@ class QPDFObjectHelper
46 { 46 {
47 } 47 }
48 QPDF_DLL 48 QPDF_DLL
49 - virtual ~QPDFObjectHelper() = default; 49 + virtual ~QPDFObjectHelper();
50 QPDF_DLL 50 QPDF_DLL
51 QPDFObjectHandle 51 QPDFObjectHandle
52 getObjectHandle() 52 getObjectHandle()
libqpdf/CMakeLists.txt
@@ -59,6 +59,7 @@ set(libqpdf_SOURCES @@ -59,6 +59,7 @@ set(libqpdf_SOURCES
59 QPDFAnnotationObjectHelper.cc 59 QPDFAnnotationObjectHelper.cc
60 QPDFArgParser.cc 60 QPDFArgParser.cc
61 QPDFCryptoProvider.cc 61 QPDFCryptoProvider.cc
  62 + QPDFDocumentHelper.cc
62 QPDFEFStreamObjectHelper.cc 63 QPDFEFStreamObjectHelper.cc
63 QPDFEmbeddedFileDocumentHelper.cc 64 QPDFEmbeddedFileDocumentHelper.cc
64 QPDFExc.cc 65 QPDFExc.cc
@@ -74,6 +75,7 @@ set(libqpdf_SOURCES @@ -74,6 +75,7 @@ set(libqpdf_SOURCES
74 QPDFNumberTreeObjectHelper.cc 75 QPDFNumberTreeObjectHelper.cc
75 QPDFObject.cc 76 QPDFObject.cc
76 QPDFObjectHandle.cc 77 QPDFObjectHandle.cc
  78 + QPDFObjectHelper.cc
77 QPDFObjGen.cc 79 QPDFObjGen.cc
78 QPDFOutlineDocumentHelper.cc 80 QPDFOutlineDocumentHelper.cc
79 QPDFOutlineObjectHelper.cc 81 QPDFOutlineObjectHelper.cc
libqpdf/QPDFDocumentHelper.cc 0 → 100644
  1 +#include <qpdf/QPDFDocumentHelper.hh>
  2 +
  3 +QPDFDocumentHelper::~QPDFDocumentHelper()
  4 +{
  5 + // Must be explicit and not inline -- see QPDF_DLL_CLASS in
  6 + // README-maintainer
  7 +}
libqpdf/QPDFObjectHelper.cc 0 → 100644
  1 +#include <qpdf/QPDFObjectHelper.hh>
  2 +
  3 +QPDFObjectHelper::~QPDFObjectHelper()
  4 +{
  5 + // Must be explicit and not inline -- see QPDF_DLL_CLASS in
  6 + // README-maintainer
  7 +}