From 27a2182974869539c66a746a5f449d8ded0fb307 Mon Sep 17 00:00:00 2001 From: Ciro Nishiguchi Date: Tue, 21 Aug 2018 13:41:43 -0500 Subject: uhd: Define UHD_API as empty string when building static lib Fixes #2484 When building uhd host as a static library on Windows, UHD_API is defined as __declspec(dllimport). This results in MSVC returning error C2491 during compilation. Added a preprocessor define UHD_STATIC_LIB in cmake and made the config headers set UHD_API to empty string when UHD_STATIC_LIB is defined. --- host/include/uhd/config.h | 14 ++++++++++---- host/include/uhd/config.hpp | 13 +++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/config.h b/host/include/uhd/config.h index 2cb399778..1aab06526 100644 --- a/host/include/uhd/config.h +++ b/host/include/uhd/config.h @@ -57,11 +57,17 @@ typedef ptrdiff_t ssize_t; #endif // API declaration macro -#ifdef UHD_DLL_EXPORTS - #define UHD_API UHD_EXPORT + +// Define API declaration macro +#ifdef UHD_STATIC_LIB + #define UHD_API #else - #define UHD_API UHD_IMPORT -#endif // UHD_DLL_EXPORTS + #ifdef UHD_DLL_EXPORTS + #define UHD_API UHD_EXPORT + #else + #define UHD_API UHD_IMPORT + #endif // UHD_DLL_EXPORTS +#endif // UHD_STATIC_LIB // Platform defines for conditional code: // Taken from boost/config/select_platform_config.hpp, diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp index 4db905b67..0f619c94a 100644 --- a/host/include/uhd/config.hpp +++ b/host/include/uhd/config.hpp @@ -82,11 +82,16 @@ typedef ptrdiff_t ssize_t; #endif // Define API declaration macro -#ifdef UHD_DLL_EXPORTS - #define UHD_API UHD_EXPORT +#ifdef UHD_STATIC_LIB + #define UHD_API #else - #define UHD_API UHD_IMPORT -#endif // UHD_DLL_EXPORTS + #ifdef UHD_DLL_EXPORTS + #define UHD_API UHD_EXPORT + #else + #define UHD_API UHD_IMPORT + #endif // UHD_DLL_EXPORTS +#endif // UHD_STATIC_LIB + #ifdef UHD_RFNOC_ENABLED #define UHD_RFNOC_API UHD_API #else -- cgit v1.2.3