bladeRF
bladeRF copied to clipboard
[libbladeRF] API_EXPORT should evaluate to dllexport only when building libbladeRF
The dllexport
entries should only be used when building the libbladerf_shared
target.
For other cases, these should be dllimport
.
A compile-time definition should be used to switch between them.
As kindly pointed out to me, this only applies for the libbladerf_shared
target.
If we added a libbladerf_static
target, we'd need to ensure we have an empty API_EXPORT
expansion.
Still an open issue! How about this in libbladeRF.h
:
#ifdef BLADERF_STATICLIB
/* Use BladeRF as a static library */
#define BLADERF_EXTERN
#elif defined(_WIN32) || defined(__CYGWIN__)
/* Defined when compiling 'host/libraries/libbladeRF/src/' .c-files */
#if defined(BUILDING_BLADERF)
#define BLADERF_EXTERN __declspec(dllexport)
#else
#define BLADERF_EXTERN __declspec(dllimport)
#endif
#else
#define BLADERF_EXTERN
#endif
And then replace API_EXPORT
with BLADERF_EXTERN
. A bit more intuitive IMHO.
I'm not sure it's possible to use BladeRF as a static library. But it could certainly prevent a .DLL-hell.