VTK  9.3.20240412
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 //
24 // When selecting which version to deprecate an API in, use the newest macro
25 // available in this header.
26 //
27 // In the implementation:
28 //
29 // ```cxx
30 // // Hide VTK_DEPRECATED_IN_9_1_0() warnings for this class.
31 // #define VTK_DEPRECATION_LEVEL 0
32 //
33 // #include "vtkLegacy.h"
34 //
35 // void oldApi()
36 // {
37 // // One of:
38 // VTK_LEGACY_BODY(oldApi, "VTK 9.1");
39 // VTK_LEGACY_REPLACED_BODY(oldApi, "VTK 9.1", newApi);
40 //
41 // // Remaining implementation.
42 // }
43 // ```
44 //
45 // Please note the `VTK_DEPRECATED_IN_` version in the `VTK_DEPRECATION_LEVEL`
46 // comment so that it can be removed when that version is finally removed.
47 //----------------------------------------------------------------------------
48 
49 // The level at which warnings should be made.
50 #ifndef VTK_DEPRECATION_LEVEL
51 // VTK defaults to deprecation of its current version.
52 #ifdef VTK_VERSION_NUMBER
53 #define VTK_DEPRECATION_LEVEL VTK_VERSION_NUMBER
54 #else
55 #define VTK_DEPRECATION_LEVEL VTK_VERSION_NUMBER_QUICK
56 #endif
57 #endif
58 
59 // API deprecated before 9.1.0 have already been removed.
60 #define VTK_MINIMUM_DEPRECATION_LEVEL VTK_VERSION_CHECK(9, 1, 0)
61 
62 // Force the deprecation level to be at least that of VTK's build
63 // configuration.
64 #if VTK_DEPRECATION_LEVEL < VTK_MINIMUM_DEPRECATION_LEVEL
65 #undef VTK_DEPRECATION_LEVEL
66 #define VTK_DEPRECATION_LEVEL VTK_MINIMUM_DEPRECATION_LEVEL
67 #endif
68 
69 // Deprecation macro support for various compilers.
70 #if 0 && __cplusplus >= 201402L
71 // This is currently hard-disabled because compilers do not mix C++ attributes
72 // and `__attribute__` extensions together well.
73 #define VTK_DEPRECATION(reason) [[deprecated(reason)]]
74 #elif defined(VTK_WRAPPING_CXX)
75 // Ignore deprecation in wrapper code.
76 #define VTK_DEPRECATION(reason)
77 #elif defined(__VTK_WRAP__)
78 #define VTK_DEPRECATION(reason) [[vtk::deprecated(reason)]]
79 #else
80 #if defined(_WIN32) || defined(_WIN64)
81 #define VTK_DEPRECATION(reason) __declspec(deprecated(reason))
82 #elif defined(__clang__)
83 #if __has_extension(attribute_deprecated_with_message)
84 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
85 #else
86 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__))
87 #endif
88 #elif defined(__GNUC__)
89 #if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))
90 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
91 #else
92 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__))
93 #endif
94 #else
95 #define VTK_DEPRECATION(reason)
96 #endif
97 #endif
98 
99 // APIs deprecated in the next release.
100 #if defined(__VTK_WRAP__)
101 #define VTK_DEPRECATED_IN_9_4_0(reason) [[vtk::deprecated(reason, "9.4.0")]]
102 #elif VTK_DEPRECATION_LEVEL >= VTK_VERSION_CHECK(9, 3, 20230807)
103 #define VTK_DEPRECATED_IN_9_4_0(reason) VTK_DEPRECATION(reason)
104 #else
105 #define VTK_DEPRECATED_IN_9_4_0(reason)
106 #endif
107 
108 // APIs deprecated in 9.3.0.
109 #if defined(__VTK_WRAP__)
110 #define VTK_DEPRECATED_IN_9_3_0(reason) [[vtk::deprecated(reason, "9.3.0")]]
111 #elif VTK_DEPRECATION_LEVEL >= VTK_VERSION_CHECK(9, 2, 20220617)
112 #define VTK_DEPRECATED_IN_9_3_0(reason) VTK_DEPRECATION(reason)
113 #else
114 #define VTK_DEPRECATED_IN_9_3_0(reason)
115 #endif
116 
117 // APIs deprecated in the older release always warn.
118 #if defined(__VTK_WRAP__)
119 #define VTK_DEPRECATED_IN_9_2_0(reason) [[vtk::deprecated(reason, "9.2.0")]]
120 #else
121 #define VTK_DEPRECATED_IN_9_2_0(reason) VTK_DEPRECATION(reason)
122 #endif
123 
124 #if defined(__VTK_WRAP__)
125 #define VTK_DEPRECATED_IN_9_1_0(reason) [[vtk::deprecated(reason, "9.1.0")]]
126 #else
127 #define VTK_DEPRECATED_IN_9_1_0(reason) VTK_DEPRECATION(reason)
128 #endif
129 
130 #if defined(__VTK_WRAP__)
131 #define VTK_DEPRECATED_IN_9_0_0(reason) [[vtk::deprecated(reason, "9.0.0")]]
132 #else
133 #define VTK_DEPRECATED_IN_9_0_0(reason) VTK_DEPRECATION(reason)
134 #endif
135 
136 #if defined(__VTK_WRAP__)
137 #define VTK_DEPRECATED_IN_8_2_0(reason) [[vtk::deprecated(reason, "8.2.0")]]
138 #else
139 #define VTK_DEPRECATED_IN_8_2_0(reason) VTK_DEPRECATION(reason)
140 #endif
141 
142 #endif
143 
144 // VTK-HeaderTest-Exclude: vtkDeprecation.h