Commit 2efec4ce7bb31524d55596051adfe9fc3d6dacb1

Authored by jbarlow83
Committed by Jay Berkenbilt
1 parent af42fe9d

Fix C++ exception handling when -fvisibility=hidden (#302)

Fix C++ exception handling when -fvisibility=hidden

Ensure that QPDFExc and QPDFSystemError are marked visible, so that their typeinfo will not be
suppressed when -fvisibility=hidden.

Details:
    https://gcc.gnu.org/wiki/Visibility
include/qpdf/DLL.h
... ... @@ -25,8 +25,13 @@
25 25  
26 26 #if defined(_WIN32) && defined(DLL_EXPORT)
27 27 # define QPDF_DLL __declspec(dllexport)
  28 +# define QPDF_DLL_EXCEPTION
  29 +#elif __GNUC__ >= 4
  30 +# define QPDF_DLL __attribute__ ((visibility ("default")))
  31 +# define QPDF_DLL_EXCEPTION __attribute__ ((visibility ("default")))
28 32 #else
29 33 # define QPDF_DLL
  34 +# define QPDF_DLL_EXCEPTION
30 35 #endif
31 36  
32 37 #endif /* QPDF_DLL_HH */
... ...
include/qpdf/QPDFExc.hh
... ... @@ -29,7 +29,7 @@
29 29 #include <string>
30 30 #include <stdexcept>
31 31  
32   -class QPDFExc: public std::runtime_error
  32 +class QPDF_DLL_EXCEPTION QPDFExc: public std::runtime_error
33 33 {
34 34 public:
35 35 QPDF_DLL
... ...
include/qpdf/QPDFSystemError.hh
... ... @@ -29,7 +29,7 @@
29 29 #include <string>
30 30 #include <stdexcept>
31 31  
32   -class QPDFSystemError: public std::runtime_error
  32 +class QPDF_DLL_EXCEPTION QPDFSystemError: public std::runtime_error
33 33 {
34 34 public:
35 35 QPDF_DLL
... ...