bladeRF icon indicating copy to clipboard operation
bladeRF copied to clipboard

[libbladeRF] API_EXPORT should evaluate to dllexport only when building libbladeRF

Open jynik opened this issue 7 years ago • 2 comments

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.

jynik avatar Jul 12 '16 16:07 jynik

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.

jynik avatar Jul 12 '16 16:07 jynik

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.

gvanem avatar Feb 28 '18 12:02 gvanem