VTK  9.2.20221001
vtkDeprecation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkDeprecation.h
5 
6 -------------------------------------------------------------------------
7  Copyright 2008 Sandia Corporation.
8  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9  the U.S. Government retains certain rights in this software.
10 -------------------------------------------------------------------------
11 
12  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
13  All rights reserved.
14  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
15 
16  This software is distributed WITHOUT ANY WARRANTY; without even
17  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18  PURPOSE. See the above copyright notice for more information.
19 
20 =========================================================================*/
21 
22 #ifndef vtkDeprecation_h
23 #define vtkDeprecation_h
24 
25 #include "vtkVersionMacros.h"
26 
27 //----------------------------------------------------------------------------
28 // These macros may be used to deprecate APIs in VTK. They act as attributes on
29 // method declarations and do not remove methods from a build based on build
30 // configuration.
31 //
32 // To use:
33 //
34 // In the declaration:
35 //
36 // ```cxx
37 // VTK_DEPRECATED_IN_9_1_0("reason for the deprecation")
38 // void oldApi();
39 // ```
40 //
41 // When selecting which version to deprecate an API in, use the newest macro
42 // available in this header.
43 //
44 // In the implementation:
45 //
46 // ```cxx
47 // // Hide VTK_DEPRECATED_IN_9_1_0() warnings for this class.
48 // #define VTK_DEPRECATION_LEVEL 0
49 //
50 // #include "vtkLegacy.h"
51 //
52 // void oldApi()
53 // {
54 // // One of:
55 // VTK_LEGACY_BODY(oldApi, "VTK 9.1");
56 // VTK_LEGACY_REPLACED_BODY(oldApi, "VTK 9.1", newApi);
57 //
58 // // Remaining implementation.
59 // }
60 // ```
61 //
62 // Please note the `VTK_DEPRECATED_IN_` version in the `VTK_DEPRECATION_LEVEL`
63 // comment so that it can be removed when that version is finally removed.
64 //----------------------------------------------------------------------------
65 
66 // The level at which warnings should be made.
67 #ifndef VTK_DEPRECATION_LEVEL
68 // VTK defaults to deprecation of its current version.
69 #define VTK_DEPRECATION_LEVEL VTK_VERSION_NUMBER
70 #endif
71 
72 // API deprecated before 9.1.0 have already been removed.
73 #define VTK_MINIMUM_DEPRECATION_LEVEL VTK_VERSION_CHECK(9, 1, 0)
74 
75 // Force the deprecation level to be at least that of VTK's build
76 // configuration.
77 #if VTK_DEPRECATION_LEVEL < VTK_MINIMUM_DEPRECATION_LEVEL
78 #undef VTK_DEPRECATION_LEVEL
79 #define VTK_DEPRECATION_LEVEL VTK_MINIMUM_DEPRECATION_LEVEL
80 #endif
81 
82 // Deprecation macro support for various compilers.
83 #if 0 && __cplusplus >= 201402L
84 // This is currently hard-disabled because compilers do not mix C++ attributes
85 // and `__attribute__` extensions together well.
86 #define VTK_DEPRECATION(reason) [[deprecated(reason)]]
87 #elif defined(VTK_WRAPPING_CXX)
88 // Ignore deprecation in wrapper code.
89 #define VTK_DEPRECATION(reason)
90 #elif defined(__VTK_WRAP__)
91 #define VTK_DEPRECATION(reason) [[vtk::deprecated(reason)]]
92 #else
93 #if defined(_WIN32) || defined(_WIN64)
94 #define VTK_DEPRECATION(reason) __declspec(deprecated(reason))
95 #elif defined(__clang__)
96 #if __has_extension(attribute_deprecated_with_message)
97 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
98 #else
99 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__))
100 #endif
101 #elif defined(__GNUC__)
102 #if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))
103 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
104 #else
105 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__))
106 #endif
107 #else
108 #define VTK_DEPRECATION(reason)
109 #endif
110 #endif
111 
112 // APIs deprecated in the next release.
113 #if defined(__VTK_WRAP__)
114 #define VTK_DEPRECATED_IN_9_3_0(reason) [[vtk::deprecated(reason, "9.3.0")]]
115 #elif VTK_DEPRECATION_LEVEL >= VTK_VERSION_CHECK(9, 2, 20220617)
116 #define VTK_DEPRECATED_IN_9_3_0(reason) VTK_DEPRECATION(reason)
117 #else
118 #define VTK_DEPRECATED_IN_9_3_0(reason)
119 #endif
120 
121 // APIs deprecated in 9.2.0.
122 #if defined(__VTK_WRAP__)
123 #define VTK_DEPRECATED_IN_9_2_0(reason) [[vtk::deprecated(reason, "9.2.0")]]
124 #elif VTK_DEPRECATION_LEVEL >= VTK_VERSION_CHECK(9, 1, 20211001)
125 #define VTK_DEPRECATED_IN_9_2_0(reason) VTK_DEPRECATION(reason)
126 #else
127 #define VTK_DEPRECATED_IN_9_2_0(reason)
128 #endif
129 
130 // APIs deprecated in the older release always warn.
131 #if defined(__VTK_WRAP__)
132 #define VTK_DEPRECATED_IN_9_1_0(reason) [[vtk::deprecated(reason, "9.1.0")]]
133 #else
134 #define VTK_DEPRECATED_IN_9_1_0(reason)
135 #endif
136 
137 #if defined(__VTK_WRAP__)
138 #define VTK_DEPRECATED_IN_9_0_0(reason) [[vtk::deprecated(reason, "9.0.0")]]
139 #else
140 #define VTK_DEPRECATED_IN_9_0_0(reason) VTK_DEPRECATION(reason)
141 #endif
142 
143 #if defined(__VTK_WRAP__)
144 #define VTK_DEPRECATED_IN_8_2_0(reason) [[vtk::deprecated(reason, "8.2.0")]]
145 #else
146 #define VTK_DEPRECATED_IN_8_2_0(reason) VTK_DEPRECATION(reason)
147 #endif
148 
149 #endif
150 
151 // VTK-HeaderTest-Exclude: vtkDeprecation.h