From 80444805898842f7e5c62b256337c0897eb254bb Mon Sep 17 00:00:00 2001 From: Jeffrey van de Glind Date: Wed, 17 Feb 2021 08:42:14 +0100 Subject: [PATCH] export http_exception for non Windows builds If a project compiled with clang for macos links to CppRest, and the -fvisibility=hidden compiler option is used, the http_exception is used as std::exception. The clang compiler requires it to be exported in order to know about the symbols. Since the Visual Studio compiler throws warnings regarding the export of a class that inherits from a non-exported class, std::exception in this case, this export is only defined for clang. --- Release/include/cpprest/details/cpprest_compat.h | 8 ++++++++ Release/include/cpprest/http_msg.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Release/include/cpprest/details/cpprest_compat.h b/Release/include/cpprest/details/cpprest_compat.h index 6dae41d8d9..bf10747987 100644 --- a/Release/include/cpprest/details/cpprest_compat.h +++ b/Release/include/cpprest/details/cpprest_compat.h @@ -71,12 +71,20 @@ #ifdef _NO_ASYNCRTIMP #define _ASYNCRTIMP +#define _ASYNCRTIMP_TYPEINFO #else // ^^^ _NO_ASYNCRTIMP ^^^ // vvv !_NO_ASYNCRTIMP vvv #ifdef _ASYNCRT_EXPORT #define _ASYNCRTIMP __declspec(dllexport) #else // ^^^ _ASYNCRT_EXPORT ^^^ // vvv !_ASYNCRT_EXPORT vvv #define _ASYNCRTIMP __declspec(dllimport) #endif // _ASYNCRT_EXPORT + +#if defined(_WIN32) +#define _ASYNCRTIMP_TYPEINFO +#else // ^^^ _WIN32 ^^^ // vvv !_WIN32 vvv +#define _ASYNCRTIMP_TYPEINFO __attribute__((visibility("default"))) +#endif // _WIN32 + #endif // _NO_ASYNCRTIMP #ifdef CASABLANCA_DEPRECATION_NO_WARNINGS diff --git a/Release/include/cpprest/http_msg.h b/Release/include/cpprest/http_msg.h index 50f05ef213..55c0433c94 100644 --- a/Release/include/cpprest/http_msg.h +++ b/Release/include/cpprest/http_msg.h @@ -187,7 +187,7 @@ class header_names /// /// Represents an HTTP error. This class holds an error message and an optional error code. /// -class http_exception : public std::exception +class _ASYNCRTIMP_TYPEINFO http_exception : public std::exception { public: ///