VTK  9.7.1
vtkDeprecation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
4 
5 #ifndef vtkDeprecation_h
6 #define vtkDeprecation_h
7 
8 #include "vtkVersionQuick.h"
9 
10 //----------------------------------------------------------------------------
11 // These macros may be used to deprecate APIs in VTK. They act as attributes on
12 // method declarations and do not remove methods from a build based on build
13 // configuration.
14 //
15 // To use:
16 //
17 // In the declaration:
18 //
19 // ```cxx
20 // VTK_DEPRECATED_IN_9_1_0("reason for the deprecation")
21 // void oldApi();
22 // ```
23 // or
24 // ```cxx
25 // class VTK_DEPRECATED_IN_X_Y_Z("reason for deprecation") OPT_EXPORT_MACRO oldClass {
26 // ```
27 //
28 // When selecting which version to deprecate an API in, use the newest macro
29 // available in this header.
30 //
31 // In the implementation:
32 //
33 // ```cxx
34 // // Hide VTK_DEPRECATED_IN_X_Y_Z() warnings for this class.
35 // #define VTK_DEPRECATION_LEVEL 0
36 //
37 // #include …
38 // ```
39 //
40 // Please note the `VTK_DEPRECATED_IN_` version in the `VTK_DEPRECATION_LEVEL`
41 // comment so that it can be removed when that version is finally removed. The
42 // macro should also be defined before any includes.
43 //----------------------------------------------------------------------------
44 
45 // The level at which warnings should be made.
46 #ifndef VTK_DEPRECATION_LEVEL
47 // VTK defaults to deprecation of its current version.
48 #ifdef VTK_VERSION_NUMBER
49 #define VTK_DEPRECATION_LEVEL VTK_VERSION_NUMBER
50 #else
51 #define VTK_DEPRECATION_LEVEL VTK_VERSION_NUMBER_QUICK
52 #endif
53 #endif
54 
55 // API deprecated before 9.5.0 have already been removed.
56 #define VTK_MINIMUM_DEPRECATION_LEVEL VTK_VERSION_CHECK(9, 5, 0)
57 
58 // Force the deprecation level to be at least that of VTK's build
59 // configuration.
60 #if VTK_DEPRECATION_LEVEL < VTK_MINIMUM_DEPRECATION_LEVEL
61 #undef VTK_DEPRECATION_LEVEL
62 #define VTK_DEPRECATION_LEVEL VTK_MINIMUM_DEPRECATION_LEVEL
63 #endif
64 
65 // Deprecation macro support for various compilers.
66 #if defined(VTK_WRAPPING_CXX)
67 // Ignore deprecation in wrapper code.
68 #define VTK_DEPRECATION(reason)
69 #elif defined(__VTK_WRAP__)
70 #define VTK_DEPRECATION(reason) [[vtk::deprecated(reason)]]
71 #else
72 #if defined(__clang__)
73 // Clang 12 and AppleClang 13 and before mix [[deprecated]] with visibility macros, and cause parser
74 // like below error: expected identifier before '__attribute__' class [[deprecated("deprecated")]]
75 // __attribute__((visibility("default"))) Foo {};
76 #if (defined(__apple_build_version__) && (__clang_major__ <= 13))
77 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
78 #elif (__clang_major__ <= 12)
79 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
80 #else
81 #define VTK_DEPRECATION(reason) [[deprecated(reason)]]
82 #endif
83 #elif defined(__GNUC__)
84 // GCC 12 and before mix [[deprecated]] with visibility macros, and cause parser like below
85 // error: expected identifier before '__attribute__'
86 // class [[deprecated("deprecated")]] __attribute__((visibility("default"))) Foo {};
87 #if (__GNUC__ <= 12)
88 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
89 #else
90 #define VTK_DEPRECATION(reason) [[deprecated(reason)]]
91 #endif
92 #else
93 #define VTK_DEPRECATION(reason) [[deprecated(reason)]]
94 #endif
95 #endif
96 
97 // APIs deprecated in the next release.
98 #if defined(__VTK_WRAP__)
99 #define VTK_DEPRECATED_IN_9_7_0(reason) [[vtk::deprecated(reason, "9.7.0")]]
100 #elif VTK_DEPRECATION_LEVEL >= VTK_VERSION_CHECK(9, 6, 20251220)
101 #define VTK_DEPRECATED_IN_9_7_0(reason) VTK_DEPRECATION(reason)
102 #else
103 #define VTK_DEPRECATED_IN_9_7_0(reason)
104 #endif
105 
106 // APIs deprecated in 9.6.0
107 #if defined(__VTK_WRAP__)
108 #define VTK_DEPRECATED_IN_9_6_0(reason) [[vtk::deprecated(reason, "9.6.0")]]
109 #elif VTK_DEPRECATION_LEVEL >= VTK_VERSION_CHECK(9, 5, 20250513)
110 #define VTK_DEPRECATED_IN_9_6_0(reason) VTK_DEPRECATION(reason)
111 #else
112 #define VTK_DEPRECATED_IN_9_6_0(reason)
113 #endif
114 
115 // APIs deprecated in the older release always warn.
116 #if defined(__VTK_WRAP__)
117 #define VTK_DEPRECATED_IN_9_5_0(reason) [[vtk::deprecated(reason, "9.5.0")]]
118 #else
119 #define VTK_DEPRECATED_IN_9_5_0(reason) VTK_DEPRECATION(reason)
120 #endif
121 
122 #if defined(__VTK_WRAP__)
123 #define VTK_DEPRECATED_IN_9_4_0(reason) [[vtk::deprecated(reason, "9.4.0")]]
124 #else
125 #define VTK_DEPRECATED_IN_9_4_0(reason) VTK_DEPRECATION(reason)
126 #endif
127 
128 #if defined(__VTK_WRAP__)
129 #define VTK_DEPRECATED_IN_9_3_0(reason) [[vtk::deprecated(reason, "9.3.0")]]
130 #else
131 #define VTK_DEPRECATED_IN_9_3_0(reason) VTK_DEPRECATION(reason)
132 #endif
133 
134 #if defined(__VTK_WRAP__)
135 #define VTK_DEPRECATED_IN_9_2_0(reason) [[vtk::deprecated(reason, "9.2.0")]]
136 #else
137 #define VTK_DEPRECATED_IN_9_2_0(reason) VTK_DEPRECATION(reason)
138 #endif
139 
140 #if defined(__VTK_WRAP__)
141 #define VTK_DEPRECATED_IN_9_1_0(reason) [[vtk::deprecated(reason, "9.1.0")]]
142 #else
143 #define VTK_DEPRECATED_IN_9_1_0(reason) VTK_DEPRECATION(reason)
144 #endif
145 
146 #if defined(__VTK_WRAP__)
147 #define VTK_DEPRECATED_IN_9_0_0(reason) [[vtk::deprecated(reason, "9.0.0")]]
148 #else
149 #define VTK_DEPRECATED_IN_9_0_0(reason) VTK_DEPRECATION(reason)
150 #endif
151 
152 #if defined(__VTK_WRAP__)
153 #define VTK_DEPRECATED_IN_8_2_0(reason) [[vtk::deprecated(reason, "8.2.0")]]
154 #else
155 #define VTK_DEPRECATED_IN_8_2_0(reason) VTK_DEPRECATION(reason)
156 #endif
157 
158 #endif
159 
160 // VTK-HeaderTest-Exclude: vtkDeprecation.h