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 179 the shared object boundary (or "shared library boundary" -- we may
180 180 use either term in comments and documentation). In particular,
181 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 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 188 IMPORTANT NOTE ABOUT QPDF_DLL_CLASS: On mingw, the vtable for a
187 189 class with some virtual methods and no pure virtual methods seems
... ...
include/qpdf/DLL.h
... ... @@ -42,14 +42,16 @@
42 42 # define QPDF_DLL
43 43 # endif
44 44 # define QPDF_DLL_PRIVATE
45   -# define QPDF_DLL_CLASS
46 45 #elif defined __GNUC__
47 46 # define QPDF_DLL __attribute__((visibility("default")))
48 47 # define QPDF_DLL_PRIVATE __attribute__((visibility("hidden")))
49   -# define QPDF_DLL_CLASS QPDF_DLL
50 48 #else
51 49 # define QPDF_DLL
52 50 # define QPDF_DLL_PRIVATE
  51 +#endif
  52 +#ifdef __GNUC__
  53 +# define QPDF_DLL_CLASS QPDF_DLL
  54 +#else
53 55 # define QPDF_DLL_CLASS
54 56 #endif
55 57  
... ... @@ -87,6 +89,9 @@ for a more in-depth discussion.
87 89 multi-platform and building both static and shared libraries that
88 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 95 * On Linux (and other similar systems):
91 96  
92 97 * Common compilers such as gcc and clang export all symbols into the
... ...
include/qpdf/QPDFDocumentHelper.hh
... ... @@ -36,7 +36,7 @@
36 36 // introduced to allow creation of higher level helper functions
37 37 // without polluting the public interface of QPDF.
38 38  
39   -class QPDFDocumentHelper
  39 +class QPDF_DLL_CLASS QPDFDocumentHelper
40 40 {
41 41 public:
42 42 QPDF_DLL
... ... @@ -45,7 +45,7 @@ class QPDFDocumentHelper
45 45 {
46 46 }
47 47 QPDF_DLL
48   - virtual ~QPDFDocumentHelper() = default;
  48 + virtual ~QPDFDocumentHelper();
49 49 QPDF_DLL
50 50 QPDF&
51 51 getQPDF()
... ...
include/qpdf/QPDFObjectHelper.hh
... ... @@ -37,7 +37,7 @@
37 37 // introduced to allow creation of higher level helper functions
38 38 // without polluting the public interface of QPDFObjectHandle.
39 39  
40   -class QPDFObjectHelper
  40 +class QPDF_DLL_CLASS QPDFObjectHelper
41 41 {
42 42 public:
43 43 QPDF_DLL
... ... @@ -46,7 +46,7 @@ class QPDFObjectHelper
46 46 {
47 47 }
48 48 QPDF_DLL
49   - virtual ~QPDFObjectHelper() = default;
  49 + virtual ~QPDFObjectHelper();
50 50 QPDF_DLL
51 51 QPDFObjectHandle
52 52 getObjectHandle()
... ...
libqpdf/CMakeLists.txt
... ... @@ -59,6 +59,7 @@ set(libqpdf_SOURCES
59 59 QPDFAnnotationObjectHelper.cc
60 60 QPDFArgParser.cc
61 61 QPDFCryptoProvider.cc
  62 + QPDFDocumentHelper.cc
62 63 QPDFEFStreamObjectHelper.cc
63 64 QPDFEmbeddedFileDocumentHelper.cc
64 65 QPDFExc.cc
... ... @@ -74,6 +75,7 @@ set(libqpdf_SOURCES
74 75 QPDFNumberTreeObjectHelper.cc
75 76 QPDFObject.cc
76 77 QPDFObjectHandle.cc
  78 + QPDFObjectHelper.cc
77 79 QPDFObjGen.cc
78 80 QPDFOutlineDocumentHelper.cc
79 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 +}
... ...