Skip to content

Commit a9df66a

Browse files
committed
fix windows export
1 parent 96321e6 commit a9df66a

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

src/iceberg/iceberg_export.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,31 @@
2727
# else
2828
# define ICEBERG_EXPORT __declspec(dllimport)
2929
# endif
30-
#else // Not Windows
30+
31+
# define ICEBERG_TEMPLATE_EXPORT ICEBERG_EXPORT
32+
33+
// Visibility for template class declarations.
34+
// Keep empty on MSVC to avoid `extern` + `dllexport` C4910 interactions.
35+
# if defined(_MSC_VER)
36+
# define ICEBERG_TEMPLATE_TYPE_EXPORT
37+
# else
38+
# define ICEBERG_TEMPLATE_TYPE_EXPORT ICEBERG_EXPORT
39+
# endif
40+
41+
// MSVC doesn't allow explicit instantiation declarations as `extern` +
42+
// `__declspec(dllexport)` (C4910).
43+
# if defined(_MSC_VER) && defined(ICEBERG_EXPORTING) && !defined(ICEBERG_STATIC)
44+
# define ICEBERG_EXTERN_TEMPLATE_EXPORT
45+
# else
46+
# define ICEBERG_EXTERN_TEMPLATE_EXPORT ICEBERG_TEMPLATE_EXPORT
47+
# endif
48+
49+
#else // Non-Windows
3150
# ifndef ICEBERG_EXPORT
3251
# define ICEBERG_EXPORT __attribute__((visibility("default")))
3352
# endif
53+
54+
# define ICEBERG_TEMPLATE_EXPORT
55+
# define ICEBERG_TEMPLATE_TYPE_EXPORT ICEBERG_EXPORT
56+
# define ICEBERG_EXTERN_TEMPLATE_EXPORT ICEBERG_TEMPLATE_EXPORT
3457
#endif

src/iceberg/util/struct_like_set.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ bool StructLikeSet<kValidate>::KeyEqual::operator()(
617617
return StructLikeEqualUnchecked(*lhs, rhs);
618618
}
619619

620-
template class StructLikeSet<true>;
621-
template class StructLikeSet<false>;
620+
template class ICEBERG_TEMPLATE_EXPORT StructLikeSet<true>;
621+
template class ICEBERG_TEMPLATE_EXPORT StructLikeSet<false>;
622622

623623
} // namespace iceberg

src/iceberg/util/struct_like_set.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace iceberg {
4545
/// only when the caller guarantees schema conformance and the validation
4646
/// overhead must be avoided.
4747
template <bool kValidate = true>
48-
class ICEBERG_EXPORT StructLikeSet {
48+
class ICEBERG_TEMPLATE_TYPE_EXPORT StructLikeSet {
4949
public:
5050
/// \brief Create a StructLikeSet for the given struct type.
5151
explicit StructLikeSet(const StructType& type);
@@ -102,7 +102,7 @@ class ICEBERG_EXPORT StructLikeSet {
102102
/// that guarantee schema conformance.
103103
using UncheckedStructLikeSet = StructLikeSet<false>;
104104

105-
extern template class StructLikeSet<true>;
106-
extern template class StructLikeSet<false>;
105+
extern template class ICEBERG_EXTERN_TEMPLATE_EXPORT StructLikeSet<true>;
106+
extern template class ICEBERG_EXTERN_TEMPLATE_EXPORT StructLikeSet<false>;
107107

108108
} // namespace iceberg

0 commit comments

Comments
 (0)