-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HEDLEY_IMPORT with C++ classes #35
Comments
@nemequ do you have any thoughts on this? |
alternatively, since c++ can still have functions: #define HEDLEY_IMPORT extern
#ifdef __cplusplus
#define HEDLEY_IMPORT_CLASS
#endif |
I've been digging into this a bit, and I think @SFGrenade's suggestion is on the right track; it doesn't seem like we can reuse the same macro for both cases. Having a second macro for classes would make sense to me. That said, I'm a bit confused about what this new macro would be defined to if not nothing? I know in MSVC you can put |
my homecooked solution is https://github.com/SFGrenade/ZmqPb-Cpp/blob/master/include/zmqPb/_export.hpp, so probably something like #if defined(HEDLEY_PRIVATE)
# undef HEDLEY_PRIVATE
#endif
#if defined(HEDLEY_PUBLIC)
# undef HEDLEY_PUBLIC
#endif
#if defined(HEDLEY_IMPORT)
# undef HEDLEY_IMPORT
#endif
#if defined(HEDLEY_IMPORT_CLASS)
# undef HEDLEY_IMPORT_CLASS
#endif
#if defined(_WIN32) || defined(__CYGWIN__)
# define HEDLEY_PRIVATE
# define HEDLEY_PUBLIC __declspec(dllexport)
# define HEDLEY_IMPORT __declspec(dllimport)
# ifdef __cplusplus
# define HEDLEY_IMPORT_CLASS HEDLEY_IMPORT
# endif
#else
# if \
HEDLEY_HAS_ATTRIBUTE(visibility) || \
HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
( \
defined(__TI_EABI__) && \
( \
(HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
) \
) || \
HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
# define HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
# define HEDLEY_PUBLIC __attribute__((__visibility__("default")))
# else
# define HEDLEY_PRIVATE
# define HEDLEY_PUBLIC
# endif
# define HEDLEY_IMPORT extern
# ifdef __cplusplus
# define HEDLEY_IMPORT_CLASS
# endif
#endif at https://github.com/nemequ/hedley/blob/master/hedley.h#L1641-L1677 |
HEDLEY_IMPORT is specificed as
extern
which fails when used as so:We would expect that
example
symbols are exported. However, when importing the result isclass extern example {};
which is invalid.A possible solution is:
The text was updated successfully, but these errors were encountered: