From 2efec4ce7bb31524d55596051adfe9fc3d6dacb1 Mon Sep 17 00:00:00 2001 From: jbarlow83 Date: Mon, 11 Mar 2019 15:28:29 -0700 Subject: 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 | 5 +++++ include/qpdf/QPDFExc.hh | 2 +- include/qpdf/QPDFSystemError.hh | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/qpdf/DLL.h b/include/qpdf/DLL.h index ccd05fce..1e5d8a1a 100644 --- a/include/qpdf/DLL.h +++ b/include/qpdf/DLL.h @@ -25,8 +25,13 @@ #if defined(_WIN32) && defined(DLL_EXPORT) # define QPDF_DLL __declspec(dllexport) +# define QPDF_DLL_EXCEPTION +#elif __GNUC__ >= 4 +# define QPDF_DLL __attribute__ ((visibility ("default"))) +# define QPDF_DLL_EXCEPTION __attribute__ ((visibility ("default"))) #else # define QPDF_DLL +# define QPDF_DLL_EXCEPTION #endif #endif /* QPDF_DLL_HH */ diff --git a/include/qpdf/QPDFExc.hh b/include/qpdf/QPDFExc.hh index fe0aa1d5..c538eb4d 100644 --- a/include/qpdf/QPDFExc.hh +++ b/include/qpdf/QPDFExc.hh @@ -29,7 +29,7 @@ #include #include -class QPDFExc: public std::runtime_error +class QPDF_DLL_EXCEPTION QPDFExc: public std::runtime_error { public: QPDF_DLL diff --git a/include/qpdf/QPDFSystemError.hh b/include/qpdf/QPDFSystemError.hh index c4e48713..cef8ea08 100644 --- a/include/qpdf/QPDFSystemError.hh +++ b/include/qpdf/QPDFSystemError.hh @@ -29,7 +29,7 @@ #include #include -class QPDFSystemError: public std::runtime_error +class QPDF_DLL_EXCEPTION QPDFSystemError: public std::runtime_error { public: QPDF_DLL -- cgit v1.2.3-54-g00ecf