Commit 31a63a45 authored by David Gobbi's avatar David Gobbi

Simplify extern template declarations for arrays

This unifies the extern template declarations between MSVC and other
compilers for C++11 compilation.  There is still some old code to
support extern template for MSVC 2008 and 2010, this code can be
removed when we drop those compilers.
parent ff7ce07d
Pipeline #25789 passed with stage
......@@ -226,9 +226,6 @@ private:
// Declare vtkArrayDownCast implementations for AoS containers:
vtkArrayDownCast_TemplateFastCastMacro(vtkAOSDataArrayTemplate)
# define VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(T) \
template class VTKCOMMONCORE_EXPORT vtkAOSDataArrayTemplate< T >
// This macro is used by the subclasses to create dummy
// declarations for these functions such that the wrapper
// can see them. The wrappers ignore vtkAOSDataArrayTemplate.
......@@ -264,9 +261,27 @@ vtkArrayDownCast_TemplateFastCastMacro(vtkAOSDataArrayTemplate)
// libraries other than vtkCommonCore that instantiations of
// vtkAOSDataArrayTemplate can be found externally. This prevents each library
// from instantiating these on their own.
#ifndef VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATING
#if defined(VTK_BUILD_SHARED_LIBS)
#if defined(_MSC_VER)
#ifdef VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATING
#define VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(T) \
template class VTKCOMMONCORE_EXPORT vtkAOSDataArrayTemplate< T >
#elif defined(VTK_USE_EXTERN_TEMPLATE)
#ifndef VTK_AOS_DATA_ARRAY_TEMPLATE_EXTERN
#define VTK_AOS_DATA_ARRAY_TEMPLATE_EXTERN
#ifdef _MSC_VER
#pragma warning (push)
// The following is needed when the vtkAOSDataArrayTemplate is declared
// dllexport and is used from another class in vtkCommonCore
#pragma warning (disable: 4910) // extern and dllexport incompatible
#endif
vtkExternTemplateMacro(
extern template class VTKCOMMONCORE_EXTERN vtkAOSDataArrayTemplate)
#ifdef _MSC_VER
#pragma warning (pop)
#endif
#endif // VTK_AOS_DATA_ARRAY_TEMPLATE_EXTERN
// The following clause is only for MSVC 2008 and 2010
#elif defined(_MSC_VER) && !defined(VTK_BUILD_SHARED_LIBS)
#pragma warning (push)
// C4091: 'extern ' : ignored on left of 'int' when no variable is declared
......@@ -290,37 +305,11 @@ vtkArrayDownCast_TemplateFastCastMacro(vtkAOSDataArrayTemplate)
// Use an "extern explicit instantiation" to give the class a DLL
// interface. This is a compiler-specific extension.
extern VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(char);
extern VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(double);
extern VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(float);
extern VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(int);
extern VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(long);
extern VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(long long);
extern VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(short);
extern VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(signed char);
extern VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(unsigned char);
extern VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(unsigned int);
extern VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(unsigned long);
extern VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(unsigned long long);
extern VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(unsigned short);
vtkInstantiateTemplateMacro(
extern template class VTKCOMMONCORE_EXPORT vtkAOSDataArrayTemplate)
#pragma warning (pop)
#elif defined(VTK_USE_EXTERN_TEMPLATE)
extern template class vtkAOSDataArrayTemplate<char>;
extern template class vtkAOSDataArrayTemplate<double>;
extern template class vtkAOSDataArrayTemplate<float>;
extern template class vtkAOSDataArrayTemplate<int>;
extern template class vtkAOSDataArrayTemplate<long>;
extern template class vtkAOSDataArrayTemplate<long long>;
extern template class vtkAOSDataArrayTemplate<short>;
extern template class vtkAOSDataArrayTemplate<signed char>;
extern template class vtkAOSDataArrayTemplate<unsigned char>;
extern template class vtkAOSDataArrayTemplate<unsigned int>;
extern template class vtkAOSDataArrayTemplate<unsigned long>;
extern template class vtkAOSDataArrayTemplate<unsigned long long>;
extern template class vtkAOSDataArrayTemplate<unsigned short>;
#endif // _MSC_VER
#endif // VTK_BUILD_SHARED_LIBS
#endif // VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATING
#endif
// VTK-HeaderTest-Exclude: vtkAOSDataArrayTemplate.h
......@@ -211,18 +211,33 @@ private:
// Declare vtkArrayDownCast implementations for SoA containers:
vtkArrayDownCast_TemplateFastCastMacro(vtkSOADataArrayTemplate)
# define VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(T) \
template class VTKCOMMONCORE_EXPORT vtkSOADataArrayTemplate< T >
#endif // header guard
// This portion must be OUTSIDE the include blockers. This is used to tell
// libraries other than vtkCommonCore that instantiations of
// vtkSOADataArrayTemplate can be found externally. This prevents each library
// from instantiating these on their own.
#ifndef VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATING
#if defined(VTK_BUILD_SHARED_LIBS)
#if defined(_MSC_VER)
#ifdef VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATING
#define VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(T) \
template class VTKCOMMONCORE_EXPORT vtkSOADataArrayTemplate< T >
#elif defined(VTK_USE_EXTERN_TEMPLATE)
#ifndef VTK_SOA_DATA_ARRAY_TEMPLATE_EXTERN
#define VTK_SOA_DATA_ARRAY_TEMPLATE_EXTERN
#ifdef _MSC_VER
#pragma warning (push)
// The following is needed when the vtkSOADataArrayTemplate is declared
// dllexport and is used from another class in vtkCommonCore
#pragma warning (disable: 4910) // extern and dllexport incompatible
#endif
vtkExternTemplateMacro(
extern template class VTKCOMMONCORE_EXTERN vtkSOADataArrayTemplate)
#ifdef _MSC_VER
#pragma warning (pop)
#endif
#endif // VTK_SOA_DATA_ARRAY_TEMPLATE_EXTERN
// The following clause is only for MSVC 2008 and 2010
#elif defined(_MSC_VER) && !defined(VTK_BUILD_SHARED_LIBS)
#pragma warning (push)
// C4091: 'extern ' : ignored on left of 'int' when no variable is declared
......@@ -246,37 +261,11 @@ vtkArrayDownCast_TemplateFastCastMacro(vtkSOADataArrayTemplate)
// Use an "extern explicit instantiation" to give the class a DLL
// interface. This is a compiler-specific extension.
extern VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(char);
extern VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(double);
extern VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(float);
extern VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(int);
extern VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(long);
extern VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(long long);
extern VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(short);
extern VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(signed char);
extern VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(unsigned char);
extern VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(unsigned int);
extern VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(unsigned long);
extern VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(unsigned long long);
extern VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATE(unsigned short);
vtkInstantiateTemplateMacro(
extern template class VTKCOMMONCORE_EXPORT vtkSOADataArrayTemplate)
#pragma warning (pop)
#elif defined(VTK_USE_EXTERN_TEMPLATE)
extern template class vtkSOADataArrayTemplate<char>;
extern template class vtkSOADataArrayTemplate<double>;
extern template class vtkSOADataArrayTemplate<float>;
extern template class vtkSOADataArrayTemplate<int>;
extern template class vtkSOADataArrayTemplate<long>;
extern template class vtkSOADataArrayTemplate<long long>;
extern template class vtkSOADataArrayTemplate<short>;
extern template class vtkSOADataArrayTemplate<signed char>;
extern template class vtkSOADataArrayTemplate<unsigned char>;
extern template class vtkSOADataArrayTemplate<unsigned int>;
extern template class vtkSOADataArrayTemplate<unsigned long>;
extern template class vtkSOADataArrayTemplate<unsigned long long>;
extern template class vtkSOADataArrayTemplate<unsigned short>;
#endif // _MSC_VER
#endif // VTK_BUILD_SHARED_LIBS
#endif // VTK_SOA_DATA_ARRAY_TEMPLATE_INSTANTIATING
#endif
// VTK-HeaderTest-Exclude: vtkSOADataArrayTemplate.h
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment