diff --git a/src/lib/ffi/ffi.h b/src/lib/ffi/ffi.h index 56551dcde9c..b437d5c69de 100644 --- a/src/lib/ffi/ffi.h +++ b/src/lib/ffi/ffi.h @@ -56,14 +56,28 @@ API follows a few simple rules: - TLS */ -#include #include #include /** -* Notes the version that this FFI function was first added +* BOTAN_FFI_EXPORT indicates public FFI functions. +* +* The arguments to the macro are to indicate the version that +* that particular FFI function was first available */ -#define BOTAN_FFI_EXPORT(maj, min) BOTAN_DLL +#if defined(BOTAN_DLL) + #define BOTAN_FFI_EXPORT(maj, min) BOTAN_DLL +#else + #if defined(__has_attribute) + #if __has_attribute(visibility) + #define BOTAN_FFI_EXPORT(maj, min) __attribute__((visibility("default"))) + #endif + #elif defined(_MSC_VER) && !defined(BOTAN_IS_BEING_BUILT) + #define BOTAN_FFI_EXPORT(maj, min) __declspec(dllimport) + #else + #define BOTAN_FFI_EXPORT(maj, min) + #endif +#endif #if !defined(BOTAN_NO_DEPRECATED_WARNINGS) #if defined(__has_attribute)