arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-627: [C++] Add compatibility macros for exported extern templates
Date Wed, 29 Mar 2017 23:53:15 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 8f386374e -> f7b287a28


ARROW-627: [C++] Add compatibility macros for exported extern templates

This should also reduce compiler warnings on MSVC

Author: Wes McKinney <wes.mckinney@twosigma.com>

Closes #447 from wesm/ARROW-627 and squashes the following commits:

3f6277d [Wes McKinney] Wrong define for msvc
b53a400 [Wes McKinney] MSVC needs export annotation when instantiating templates
8a9fcb4 [Wes McKinney] Add compatibility macros for exported extern templates, also to reduce
compiler warnings in MSVC


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/f7b287a2
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/f7b287a2
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/f7b287a2

Branch: refs/heads/master
Commit: f7b287a28d62c6b246665da7eee50fe222ebaaeb
Parents: 8f38637
Author: Wes McKinney <wes.mckinney@twosigma.com>
Authored: Wed Mar 29 19:53:08 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Wed Mar 29 19:53:08 2017 -0400

----------------------------------------------------------------------
 cpp/src/arrow/array.cc          | 32 +++++++++++++--------------
 cpp/src/arrow/array.h           | 43 ++++++++++++++----------------------
 cpp/src/arrow/tensor.cc         | 22 +++++++++---------
 cpp/src/arrow/tensor.h          | 33 +++++++++------------------
 cpp/src/arrow/type.h            |  4 ++--
 cpp/src/arrow/util/visibility.h | 17 ++++++++++++++
 6 files changed, 73 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/f7b287a2/cpp/src/arrow/array.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array.cc b/cpp/src/arrow/array.cc
index 3ea0333..b25411a 100644
--- a/cpp/src/arrow/array.cc
+++ b/cpp/src/arrow/array.cc
@@ -445,21 +445,21 @@ Status Array::Accept(ArrayVisitor* visitor) const {
 // ----------------------------------------------------------------------
 // Instantiate templates
 
-template class NumericArray<UInt8Type>;
-template class NumericArray<UInt16Type>;
-template class NumericArray<UInt32Type>;
-template class NumericArray<UInt64Type>;
-template class NumericArray<Int8Type>;
-template class NumericArray<Int16Type>;
-template class NumericArray<Int32Type>;
-template class NumericArray<Int64Type>;
-template class NumericArray<TimestampType>;
-template class NumericArray<Date32Type>;
-template class NumericArray<Date64Type>;
-template class NumericArray<Time32Type>;
-template class NumericArray<Time64Type>;
-template class NumericArray<HalfFloatType>;
-template class NumericArray<FloatType>;
-template class NumericArray<DoubleType>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<UInt8Type>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<UInt16Type>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<UInt32Type>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<UInt64Type>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<Int8Type>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<Int16Type>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<Int32Type>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<Int64Type>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<TimestampType>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<Date32Type>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<Date64Type>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<Time32Type>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<Time64Type>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<HalfFloatType>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<FloatType>;
+template class ARROW_TEMPLATE_EXPORT NumericArray<DoubleType>;
 
 }  // namespace arrow

http://git-wip-us.apache.org/repos/asf/arrow/blob/f7b287a2/cpp/src/arrow/array.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array.h b/cpp/src/arrow/array.h
index c0ec571..53b6408 100644
--- a/cpp/src/arrow/array.h
+++ b/cpp/src/arrow/array.h
@@ -483,34 +483,23 @@ class ARROW_EXPORT DictionaryArray : public Array {
 // ----------------------------------------------------------------------
 // extern templates and other details
 
-// gcc and clang disagree about how to handle template visibility when you have
-// explicit specializations https://llvm.org/bugs/show_bug.cgi?id=24815
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wattributes"
-#endif
-
 // Only instantiate these templates once
-extern template class ARROW_EXPORT NumericArray<Int8Type>;
-extern template class ARROW_EXPORT NumericArray<UInt8Type>;
-extern template class ARROW_EXPORT NumericArray<Int16Type>;
-extern template class ARROW_EXPORT NumericArray<UInt16Type>;
-extern template class ARROW_EXPORT NumericArray<Int32Type>;
-extern template class ARROW_EXPORT NumericArray<UInt32Type>;
-extern template class ARROW_EXPORT NumericArray<Int64Type>;
-extern template class ARROW_EXPORT NumericArray<UInt64Type>;
-extern template class ARROW_EXPORT NumericArray<HalfFloatType>;
-extern template class ARROW_EXPORT NumericArray<FloatType>;
-extern template class ARROW_EXPORT NumericArray<DoubleType>;
-extern template class ARROW_EXPORT NumericArray<Date32Type>;
-extern template class ARROW_EXPORT NumericArray<Date64Type>;
-extern template class ARROW_EXPORT NumericArray<Time32Type>;
-extern template class ARROW_EXPORT NumericArray<Time64Type>;
-extern template class ARROW_EXPORT NumericArray<TimestampType>;
-
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
+ARROW_EXTERN_TEMPLATE NumericArray<Int8Type>;
+ARROW_EXTERN_TEMPLATE NumericArray<UInt8Type>;
+ARROW_EXTERN_TEMPLATE NumericArray<Int16Type>;
+ARROW_EXTERN_TEMPLATE NumericArray<UInt16Type>;
+ARROW_EXTERN_TEMPLATE NumericArray<Int32Type>;
+ARROW_EXTERN_TEMPLATE NumericArray<UInt32Type>;
+ARROW_EXTERN_TEMPLATE NumericArray<Int64Type>;
+ARROW_EXTERN_TEMPLATE NumericArray<UInt64Type>;
+ARROW_EXTERN_TEMPLATE NumericArray<HalfFloatType>;
+ARROW_EXTERN_TEMPLATE NumericArray<FloatType>;
+ARROW_EXTERN_TEMPLATE NumericArray<DoubleType>;
+ARROW_EXTERN_TEMPLATE NumericArray<Date32Type>;
+ARROW_EXTERN_TEMPLATE NumericArray<Date64Type>;
+ARROW_EXTERN_TEMPLATE NumericArray<Time32Type>;
+ARROW_EXTERN_TEMPLATE NumericArray<Time64Type>;
+ARROW_EXTERN_TEMPLATE NumericArray<TimestampType>;
 
 }  // namespace arrow
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/f7b287a2/cpp/src/arrow/tensor.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/tensor.cc b/cpp/src/arrow/tensor.cc
index 6489cd0..7c4593f 100644
--- a/cpp/src/arrow/tensor.cc
+++ b/cpp/src/arrow/tensor.cc
@@ -100,16 +100,16 @@ NumericTensor<T>::NumericTensor(const std::shared_ptr<Buffer>&
data,
     const std::vector<int64_t>& shape, const std::vector<int64_t>& strides)
     : NumericTensor(data, shape, strides, {}) {}
 
-template class NumericTensor<Int8Type>;
-template class NumericTensor<UInt8Type>;
-template class NumericTensor<Int16Type>;
-template class NumericTensor<UInt16Type>;
-template class NumericTensor<Int32Type>;
-template class NumericTensor<UInt32Type>;
-template class NumericTensor<Int64Type>;
-template class NumericTensor<UInt64Type>;
-template class NumericTensor<HalfFloatType>;
-template class NumericTensor<FloatType>;
-template class NumericTensor<DoubleType>;
+template class ARROW_TEMPLATE_EXPORT NumericTensor<Int8Type>;
+template class ARROW_TEMPLATE_EXPORT NumericTensor<UInt8Type>;
+template class ARROW_TEMPLATE_EXPORT NumericTensor<Int16Type>;
+template class ARROW_TEMPLATE_EXPORT NumericTensor<UInt16Type>;
+template class ARROW_TEMPLATE_EXPORT NumericTensor<Int32Type>;
+template class ARROW_TEMPLATE_EXPORT NumericTensor<UInt32Type>;
+template class ARROW_TEMPLATE_EXPORT NumericTensor<Int64Type>;
+template class ARROW_TEMPLATE_EXPORT NumericTensor<UInt64Type>;
+template class ARROW_TEMPLATE_EXPORT NumericTensor<HalfFloatType>;
+template class ARROW_TEMPLATE_EXPORT NumericTensor<FloatType>;
+template class ARROW_TEMPLATE_EXPORT NumericTensor<DoubleType>;
 
 }  // namespace arrow

http://git-wip-us.apache.org/repos/asf/arrow/blob/f7b287a2/cpp/src/arrow/tensor.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/tensor.h b/cpp/src/arrow/tensor.h
index 0059368..7bee867 100644
--- a/cpp/src/arrow/tensor.h
+++ b/cpp/src/arrow/tensor.h
@@ -129,29 +129,18 @@ class ARROW_EXPORT NumericTensor : public Tensor {
 // ----------------------------------------------------------------------
 // extern templates and other details
 
-// gcc and clang disagree about how to handle template visibility when you have
-// explicit specializations https://llvm.org/bugs/show_bug.cgi?id=24815
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wattributes"
-#endif
-
 // Only instantiate these templates once
-extern template class ARROW_EXPORT NumericTensor<Int8Type>;
-extern template class ARROW_EXPORT NumericTensor<UInt8Type>;
-extern template class ARROW_EXPORT NumericTensor<Int16Type>;
-extern template class ARROW_EXPORT NumericTensor<UInt16Type>;
-extern template class ARROW_EXPORT NumericTensor<Int32Type>;
-extern template class ARROW_EXPORT NumericTensor<UInt32Type>;
-extern template class ARROW_EXPORT NumericTensor<Int64Type>;
-extern template class ARROW_EXPORT NumericTensor<UInt64Type>;
-extern template class ARROW_EXPORT NumericTensor<HalfFloatType>;
-extern template class ARROW_EXPORT NumericTensor<FloatType>;
-extern template class ARROW_EXPORT NumericTensor<DoubleType>;
-
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
+ARROW_EXTERN_TEMPLATE NumericTensor<Int8Type>;
+ARROW_EXTERN_TEMPLATE NumericTensor<UInt8Type>;
+ARROW_EXTERN_TEMPLATE NumericTensor<Int16Type>;
+ARROW_EXTERN_TEMPLATE NumericTensor<UInt16Type>;
+ARROW_EXTERN_TEMPLATE NumericTensor<Int32Type>;
+ARROW_EXTERN_TEMPLATE NumericTensor<UInt32Type>;
+ARROW_EXTERN_TEMPLATE NumericTensor<Int64Type>;
+ARROW_EXTERN_TEMPLATE NumericTensor<UInt64Type>;
+ARROW_EXTERN_TEMPLATE NumericTensor<HalfFloatType>;
+ARROW_EXTERN_TEMPLATE NumericTensor<FloatType>;
+ARROW_EXTERN_TEMPLATE NumericTensor<DoubleType>;
 
 }  // namespace arrow
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/f7b287a2/cpp/src/arrow/type.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/type.h b/cpp/src/arrow/type.h
index dc50ecd..2a73f6b 100644
--- a/cpp/src/arrow/type.h
+++ b/cpp/src/arrow/type.h
@@ -439,7 +439,7 @@ struct ARROW_EXPORT UnionType : public NestedType {
 
 enum class DateUnit : char { DAY = 0, MILLI = 1 };
 
-struct DateType : public FixedWidthType {
+struct ARROW_EXPORT DateType : public FixedWidthType {
  public:
   DateUnit unit;
 
@@ -496,7 +496,7 @@ static inline std::ostream& operator<<(std::ostream& os,
TimeUnit unit) {
   return os;
 }
 
-struct TimeType : public FixedWidthType {
+struct ARROW_EXPORT TimeType : public FixedWidthType {
  public:
   TimeUnit unit;
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/f7b287a2/cpp/src/arrow/util/visibility.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/visibility.h b/cpp/src/arrow/util/visibility.h
index 4819a00..6382f7f 100644
--- a/cpp/src/arrow/util/visibility.h
+++ b/cpp/src/arrow/util/visibility.h
@@ -35,4 +35,21 @@
 #endif
 #endif  // Non-Windows
 
+// gcc and clang disagree about how to handle template visibility when you have
+// explicit specializations https://llvm.org/bugs/show_bug.cgi?id=24815
+
+#if defined(__clang__)
+  #define ARROW_EXTERN_TEMPLATE extern template class ARROW_EXPORT
+#else
+  #define ARROW_EXTERN_TEMPLATE extern template class
+#endif
+
+// This is a complicated topic, some reading on it:
+// http://www.codesynthesis.com/~boris/blog/2010/01/18/dll-export-cxx-templates/
+#if defined(_MSC_VER)
+  #define ARROW_TEMPLATE_EXPORT ARROW_EXPORT
+#else
+  #define ARROW_TEMPLATE_EXPORT
+#endif
+
 #endif  // ARROW_UTIL_VISIBILITY_H


Mime
View raw message