Use __has_declspec_attribute for shared builds
Clang compilation targets may support `__declspec` attributes. Because of that it has a `__has_declspec_attribute` [check](https://clang.llvm.org/docs/LanguageExtensions.html#has-declspec-attribute). Currently libpsl just assumes that `__declspec` is Windows only. This adds a compatibility macro and checks whether `dllimport` and `dllexport` are available.
This commit is contained in:
parent
a3bd08fbf2
commit
02648135c9
|
@ -40,12 +40,17 @@
|
||||||
#define PSL_VERSION_PATCH @LIBPSL_VERSION_PATCH@
|
#define PSL_VERSION_PATCH @LIBPSL_VERSION_PATCH@
|
||||||
#define PSL_VERSION_NUMBER @LIBPSL_VERSION_NUMBER@
|
#define PSL_VERSION_NUMBER @LIBPSL_VERSION_NUMBER@
|
||||||
|
|
||||||
|
// support clang's __has_declspec_attribute attribute
|
||||||
|
#ifndef __has_declspec_attribute
|
||||||
|
# define __has_declspec_attribute(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef PSL_API
|
#ifndef PSL_API
|
||||||
#if defined BUILDING_PSL && HAVE_VISIBILITY
|
#if defined BUILDING_PSL && HAVE_VISIBILITY
|
||||||
# define PSL_API __attribute__ ((__visibility__("default")))
|
# define PSL_API __attribute__ ((__visibility__("default")))
|
||||||
#elif defined BUILDING_PSL && defined _MSC_VER && !defined PSL_STATIC
|
#elif defined BUILDING_PSL && (defined _MSC_VER || __has_declspec_attribute(dllexport)) && !defined PSL_STATIC
|
||||||
# define PSL_API __declspec(dllexport)
|
# define PSL_API __declspec(dllexport)
|
||||||
#elif defined _MSC_VER && !defined PSL_STATIC
|
#elif (defined _MSC_VER || __has_declspec_attribute(dllimport)) && !defined PSL_STATIC
|
||||||
# define PSL_API __declspec(dllimport)
|
# define PSL_API __declspec(dllimport)
|
||||||
#else
|
#else
|
||||||
# define PSL_API
|
# define PSL_API
|
||||||
|
|
Loading…
Reference in New Issue