Skip to content

Commit 589b7f0

Browse files
committed
fix windows export
1 parent 96321e6 commit 589b7f0

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

src/iceberg/iceberg_export.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,27 @@
3232
# define ICEBERG_EXPORT __attribute__((visibility("default")))
3333
# endif
3434
#endif
35+
36+
// Template export attributes require compiler-specific handling.
37+
// See: http://www.codesynthesis.com/~boris/blog/2010/01/18/dll-export-cxx-templates/
38+
#if defined(_WIN32) || defined(__CYGWIN__)
39+
# define ICEBERG_TEMPLATE_EXPORT ICEBERG_EXPORT
40+
#else
41+
# define ICEBERG_TEMPLATE_EXPORT
42+
#endif
43+
44+
// Visibility for template class declarations.
45+
// Keep empty on MSVC to avoid `extern` + `dllexport` C4910 interactions.
46+
#if defined(_MSC_VER)
47+
# define ICEBERG_TEMPLATE_TYPE_EXPORT
48+
#else
49+
# define ICEBERG_TEMPLATE_TYPE_EXPORT ICEBERG_EXPORT
50+
#endif
51+
52+
// MSVC doesn't allow explicit instantiation declarations as `extern` +
53+
// `__declspec(dllexport)` (C4910).
54+
#if defined(_MSC_VER) && defined(ICEBERG_EXPORTING) && !defined(ICEBERG_STATIC)
55+
# define ICEBERG_EXTERN_TEMPLATE_EXPORT
56+
#else
57+
# define ICEBERG_EXTERN_TEMPLATE_EXPORT ICEBERG_TEMPLATE_EXPORT
58+
#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)