VTK  9.3.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 "vtkVersionMacros.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 #define VTK_DEPRECATION_LEVEL VTK_VERSION_NUMBER
53 #endif
54 
55 // API deprecated before 9.1.0 have already been removed.
56 #define VTK_MINIMUM_DEPRECATION_LEVEL VTK_VERSION_CHECK(9, 1, 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 0 && __cplusplus >= 201402L
67 // This is currently hard-disabled because compilers do not mix C++ attributes
68 // and `__attribute__` extensions together well.
69 #define VTK_DEPRECATION(reason) [[deprecated(reason)]]
70 #elif defined(VTK_WRAPPING_CXX)
71 // Ignore deprecation in wrapper code.
72 #define VTK_DEPRECATION(reason)
73 #elif defined(__VTK_WRAP__)
74 #define VTK_DEPRECATION(reason) [[vtk::deprecated(reason)]]
75 #else
76 #if defined(_WIN32) || defined(_WIN64)
77 #define VTK_DEPRECATION(reason) __declspec(deprecated(reason))
78 #elif defined(__clang__)
79 #if __has_extension(attribute_deprecated_with_message)
80 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
81 #else
82 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__))
83 #endif
84 #elif defined(__GNUC__)
85 #if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))
86 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
87 #else
88 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__))
89 #endif
90 #else
91 #define VTK_DEPRECATION(reason)
92 #endif
93 #endif
94 
95 // APIs deprecated in the next release.
96 #if defined(__VTK_WRAP__)
97 #define VTK_DEPRECATED_IN_9_3_0(reason) [[vtk::deprecated(reason, "9.3.0")]]
98 #elif VTK_DEPRECATION_LEVEL >= VTK_VERSION_CHECK(9, 2, 20220617)
99 #define VTK_DEPRECATED_IN_9_3_0(reason) VTK_DEPRECATION(reason)
100 #else
101 #define VTK_DEPRECATED_IN_9_3_0(reason)
102 #endif
103 
104 // APIs deprecated in 9.2.0.
105 #if defined(__VTK_WRAP__)
106 #define VTK_DEPRECATED_IN_9_2_0(reason) [[vtk::deprecated(reason, "9.2.0")]]
107 #elif VTK_DEPRECATION_LEVEL >= VTK_VERSION_CHECK(9, 1, 20211001)
108 #define VTK_DEPRECATED_IN_9_2_0(reason) VTK_DEPRECATION(reason)
109 #else
110 #define VTK_DEPRECATED_IN_9_2_0(reason)
111 #endif
112 
113 // APIs deprecated in the older release always warn.
114 #if defined(__VTK_WRAP__)
115 #define VTK_DEPRECATED_IN_9_1_0(reason) [[vtk::deprecated(reason, "9.1.0")]]
116 #else
117 #define VTK_DEPRECATED_IN_9_1_0(reason)
118 #endif
119 
120 #if defined(__VTK_WRAP__)
121 #define VTK_DEPRECATED_IN_9_0_0(reason) [[vtk::deprecated(reason, "9.0.0")]]
122 #else
123 #define VTK_DEPRECATED_IN_9_0_0(reason) VTK_DEPRECATION(reason)
124 #endif
125 
126 #if defined(__VTK_WRAP__)
127 #define VTK_DEPRECATED_IN_8_2_0(reason) [[vtk::deprecated(reason, "8.2.0")]]
128 #else
129 #define VTK_DEPRECATED_IN_8_2_0(reason) VTK_DEPRECATION(reason)
130 #endif
131 
132 #endif
133 
134 // VTK-HeaderTest-Exclude: vtkDeprecation.h