diff options
author | Steven Koo <steven.koo@ni.com> | 2022-01-04 12:40:37 -0600 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-01-31 13:56:12 -0600 |
commit | 1b3ed2072e9e0101c4fc1906ccbf977c55b9f482 (patch) | |
tree | b9072e34e69a21b37b099d2cba7a60a91fa90e0d /host/include | |
parent | 5ad27a59ec09fb2e55a37993eb8992c8df83cb8b (diff) | |
download | uhd-1b3ed2072e9e0101c4fc1906ccbf977c55b9f482.tar.gz uhd-1b3ed2072e9e0101c4fc1906ccbf977c55b9f482.tar.bz2 uhd-1b3ed2072e9e0101c4fc1906ccbf977c55b9f482.zip |
rfnoc: set UHD_API_HEADER on property_t
UHD_API sets the visibility for the symbols. Adding UHD_API fixes
casting issues seen on macOS. However this breaks Windows because
UHD_API sets __declspec(dllexport) and __declspec(dllimport) which
doesn't make sense for header/inline only definitions. This change
adds UHD_API_HEADER to denote entrypoints for this case. It sets
the visibility flags for Linux/Mac but does not set the
__declspec on Windows.
Signed-off-by: Steven Koo <steven.koo@ni.com>
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/config.h | 22 | ||||
-rw-r--r-- | host/include/uhd/config.hpp | 20 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/property.hpp | 9 |
3 files changed, 45 insertions, 6 deletions
diff --git a/host/include/uhd/config.h b/host/include/uhd/config.h index c7184ea4d..a6c05f0c4 100644 --- a/host/include/uhd/config.h +++ b/host/include/uhd/config.h @@ -24,6 +24,8 @@ typedef SSIZE_T ssize_t; #if defined(_MSC_VER) #define UHD_EXPORT __declspec(dllexport) #define UHD_IMPORT __declspec(dllimport) + #define UHD_EXPORT_HEADER + #define UHD_IMPORT_HEADER #define UHD_INLINE __forceinline #define UHD_DEPRECATED __declspec(deprecated) #define UHD_ALIGNED(x) __declspec(align(x)) @@ -31,6 +33,8 @@ typedef SSIZE_T ssize_t; #elif defined(__MINGW32__) #define UHD_EXPORT __declspec(dllexport) #define UHD_IMPORT __declspec(dllimport) + #define UHD_EXPORT_HEADER + #define UHD_IMPORT_HEADER #define UHD_INLINE inline #define UHD_DEPRECATED __declspec(deprecated) #define UHD_ALIGNED(x) __declspec(align(x)) @@ -38,6 +42,8 @@ typedef SSIZE_T ssize_t; #elif defined(__GNUC__) && __GNUC__ >= 4 #define UHD_EXPORT __attribute__((visibility("default"))) #define UHD_IMPORT __attribute__((visibility("default"))) + #define UHD_EXPORT_HEADER __attribute__((visibility("default"))) + #define UHD_IMPORT_HEADER __attribute__((visibility("default"))) #define UHD_INLINE inline __attribute__((always_inline)) #define UHD_DEPRECATED __attribute__((deprecated)) #define UHD_ALIGNED(x) __attribute__((aligned(x))) @@ -45,6 +51,8 @@ typedef SSIZE_T ssize_t; #elif defined(__clang__) #define UHD_EXPORT __attribute__((visibility("default"))) #define UHD_IMPORT __attribute__((visibility("default"))) + #define UHD_EXPORT_HEADER __attribute__((visibility("default"))) + #define UHD_IMPORT_HEADER __attribute__((visibility("default"))) #define UHD_INLINE inline __attribute__((always_inline)) #define UHD_DEPRECATED __attribute__((deprecated)) #define UHD_ALIGNED(x) __attribute__((aligned(x))) @@ -52,22 +60,32 @@ typedef SSIZE_T ssize_t; #else #define UHD_EXPORT #define UHD_IMPORT + #define UHD_EXPORT_HEADER + #define UHD_IMPORT_HEADER #define UHD_INLINE inline #define UHD_DEPRECATED #define UHD_ALIGNED(x) #define UHD_UNUSED(x) x #endif -// API declaration macro - // Define API declaration macro +// +// UHD_API should be used for classes/structs that +// have a direct cpp implementations that get directly +// built into a so/dylib/dll. +// +// UHD_API_HEADER should be used for classes/structs +// that are implemented in header only like hpp/ipp. #ifdef UHD_STATIC_LIB #define UHD_API + #define UHD_API_HEADER #else #ifdef UHD_DLL_EXPORTS #define UHD_API UHD_EXPORT + #define UHD_API_HEADER UHD_EXPORT_HEADER #else #define UHD_API UHD_IMPORT + #define UHD_API_HEADER UHD_IMPORT_HEADER #endif // UHD_DLL_EXPORTS #endif // UHD_STATIC_LIB diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp index c2b3f7f45..3fae77085 100644 --- a/host/include/uhd/config.hpp +++ b/host/include/uhd/config.hpp @@ -50,6 +50,8 @@ typedef SSIZE_T ssize_t; #if defined(BOOST_MSVC) # define UHD_EXPORT __declspec(dllexport) # define UHD_IMPORT __declspec(dllimport) +# define UHD_EXPORT_HEADER +# define UHD_IMPORT_HEADER # define UHD_INLINE __forceinline # define UHD_FORCE_INLINE __forceinline # define UHD_DEPRECATED __declspec(deprecated) @@ -61,6 +63,8 @@ typedef SSIZE_T ssize_t; #elif defined(__MINGW32__) # define UHD_EXPORT __declspec(dllexport) # define UHD_IMPORT __declspec(dllimport) +# define UHD_EXPORT_HEADER +# define UHD_IMPORT_HEADER # define UHD_INLINE inline # define UHD_FORCE_INLINE inline # define UHD_DEPRECATED __declspec(deprecated) @@ -72,6 +76,8 @@ typedef SSIZE_T ssize_t; #elif defined(__GNUG__) && __GNUG__ >= 4 # define UHD_EXPORT __attribute__((visibility("default"))) # define UHD_IMPORT __attribute__((visibility("default"))) +# define UHD_EXPORT_HEADER __attribute__((visibility("default"))) +# define UHD_IMPORT_HEADER __attribute__((visibility("default"))) # define UHD_INLINE inline __attribute__((always_inline)) # define UHD_FORCE_INLINE inline __attribute__((always_inline)) # define UHD_DEPRECATED __attribute__((deprecated)) @@ -87,6 +93,8 @@ typedef SSIZE_T ssize_t; #elif defined(__clang__) # define UHD_EXPORT __attribute__((visibility("default"))) # define UHD_IMPORT __attribute__((visibility("default"))) +# define UHD_EXPORT_HEADER __attribute__((visibility("default"))) +# define UHD_IMPORT_HEADER __attribute__((visibility("default"))) # define UHD_INLINE inline __attribute__((always_inline)) # define UHD_FORCE_INLINE inline __attribute__((always_inline)) # define UHD_DEPRECATED __attribute__((deprecated)) @@ -102,6 +110,8 @@ typedef SSIZE_T ssize_t; #else # define UHD_EXPORT # define UHD_IMPORT +# define UHD_EXPORT_HEADER +# define UHD_IMPORT_HEADER # define UHD_INLINE inline # define UHD_FORCE_INLINE inline # define UHD_DEPRECATED @@ -113,13 +123,23 @@ typedef SSIZE_T ssize_t; #endif // Define API declaration macro +// +// UHD_API should be used for classes/structs that +// have a direct cpp implementations that get directly +// built into a so/dylib/dll. +// +// UHD_API_HEADER should be used for classes/structs +// that are implemented in header only like hpp/ipp. #ifdef UHD_STATIC_LIB # define UHD_API +# define UHD_API_HEADER #else # ifdef UHD_DLL_EXPORTS # define UHD_API UHD_EXPORT +# define UHD_API_HEADER UHD_EXPORT_HEADER # else # define UHD_API UHD_IMPORT +# define UHD_API_HEADER UHD_IMPORT_HEADER # endif // UHD_DLL_EXPORTS #endif // UHD_STATIC_LIB diff --git a/host/include/uhd/rfnoc/property.hpp b/host/include/uhd/rfnoc/property.hpp index e7642a6f1..3d88425da 100644 --- a/host/include/uhd/rfnoc/property.hpp +++ b/host/include/uhd/rfnoc/property.hpp @@ -36,14 +36,15 @@ public: property_base_t(const std::string& id, const res_source_info& source_info) : _id(id), _source_info(source_info) { - if(_id.find(':') != std::string::npos) { - throw uhd::value_error("Property ID `" + _id + "' contains invalid character!"); + if (_id.find(':') != std::string::npos) { + throw uhd::value_error( + "Property ID `" + _id + "' contains invalid character!"); } } virtual ~property_base_t() { - //nop + // nop } //! Gets the ID (name) of this property @@ -146,7 +147,7 @@ private: * An encapsulation class for a block property. */ template <typename data_t> -class property_t : public property_base_t +class UHD_API_HEADER property_t : public property_base_t { public: //! We want to be good C++ citizens |