summarylogtreecommitdiffstats
path: root/MR13293.patch
blob: 664c52cd5bb3445d9bdbebc43fb5e89f41ec2dca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
From 5fde5907b636662a1ce1c3c99a0242d0b707a888 Mon Sep 17 00:00:00 2001
From: Julien Schueller <schueller@phimeca.com>
Date: Thu, 28 May 2026 16:47:58 +0200
Subject: [PATCH 1/2] Common/Core: Fix MinGW GCC extern template IsTypeOf for
 vtkAOSDataArrayTemplate

Add an out-of-line IsTypeOf specialization to
vtkAOSDataArrayTemplateInstantiate.cxx.inc.in and reorder the CMake
instantiation list so it comes first. This ensures the specialization
is compiled before extern template declarations from transitively
included headers (vtkImplicitArray.txx) can trigger the
"specialization after instantiation" error on MinGW GCC.
---
 Common/Core/CMakeLists.txt                       |  6 ++++--
 ...vtkAOSDataArrayTemplateInstantiate.cxx.inc.in | 16 ++++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/Common/Core/CMakeLists.txt b/Common/Core/CMakeLists.txt
index 2f78dc2192a..93768537b30 100644
--- a/Common/Core/CMakeLists.txt
+++ b/Common/Core/CMakeLists.txt
@@ -205,8 +205,11 @@ foreach (INSTANTIATION_VALUE_TYPE IN LISTS vtk_numeric_types)
   # create a file suffix from the type
   string(REPLACE " " "_" _suffix "${INSTANTIATION_VALUE_TYPE}")
 
-  # Order of this list is important with bulk instantiation
+  # vtkAOSDataArrayTemplateInstantiate must come before anything that
+  # transitively includes vtkAOSDataArrayTemplate.h (e.g. vtkImplicitArray.txx),
+  # so the explicit instantiation precedes extern template declarations.
   set(_list
+    vtkAOSDataArrayTemplateInstantiate
     vtkAffineImplicitBackendInstantiate
     vtkCompositeImplicitBackendInstantiate
     vtkConstantImplicitBackendInstantiate
@@ -214,7 +217,6 @@ foreach (INSTANTIATION_VALUE_TYPE IN LISTS vtk_numeric_types)
     vtkStridedImplicitBackendInstantiate
     vtkStructuredPointBackendInstantiate
     vtkAffineArrayInstantiate
-    vtkAOSDataArrayTemplateInstantiate
     vtkCompositeArrayInstantiate
     vtkConstantArrayInstantiate
     vtkIndexedArrayInstantiate
diff --git a/Common/Core/vtkAOSDataArrayTemplateInstantiate.cxx.inc.in b/Common/Core/vtkAOSDataArrayTemplateInstantiate.cxx.inc.in
index 5e4043af84a..49faf35e7da 100644
--- a/Common/Core/vtkAOSDataArrayTemplateInstantiate.cxx.in
+++ b/Common/Core/vtkAOSDataArrayTemplateInstantiate.cxx.in
@@ -6,4 +6,20 @@
 #define VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATING
 #include "vtkAOSDataArrayTemplate.txx"
 
+// Out-of-line IsTypeOf for MinGW GCC extern template compatibility.
+// Must appear before explicit instantiation.
+VTK_ABI_NAMESPACE_BEGIN
+template <>
+VTKCOMMONCORE_EXPORT vtkTypeBool vtkAOSDataArrayTemplate<@INSTANTIATION_VALUE_TYPE@>::IsTypeOf(const char* type)
+{
+  typedef vtkAOSDataArrayTemplate<@INSTANTIATION_VALUE_TYPE@> SelfType;
+  if (!strcmp(typeid(SelfType).name(), type))
+  {
+    return 1;
+  }
+  return vtkGenericDataArray<SelfType, @INSTANTIATION_VALUE_TYPE@,
+    vtkArrayTypes::VTK_AOS_DATA_ARRAY>::IsTypeOf(type);
+}
+VTK_ABI_NAMESPACE_END
+
 VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(@INSTANTIATION_VALUE_TYPE@);
-- 
GitLab