vtkParaViewDeprecation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
4 
5 #ifndef vtkParaViewDeprecation_h
6 #define vtkParaViewDeprecation_h
7 
8 #include "vtkPVVersion.h"
9 
10 //----------------------------------------------------------------------------
11 // These macros may be used to deprecate APIs in ParaView. They act as
12 // attributes on method declarations and do not remove methods from a build
13 // based on build configuration.
14 //
15 // To use:
16 //
17 // In the declaration:
18 //
19 // ```cxx
20 // PARAVIEW_DEPRECATED_IN_X_Y_Z("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 PARAVIEW_DEPRECATED_IN_X_Y_Z() warnings for this class.
31 // #define PARAVIEW_DEPRECATION_LEVEL 0
32 //
33 // #include "vtkLegacy.h"
34 //
35 // void oldApi()
36 // {
37 // // One of:
38 // VTK_LEGACY_BODY(oldApi, "ParaView X.Y.Z");
39 // VTK_LEGACY_REPLACED_BODY(oldApi, "ParaView X.Y.Z", newApi);
40 //
41 // // Remaining implementation.
42 // }
43 // ```
44 //
45 // Please note the `PARAVIEW_DEPRECATED_IN_` version in the
46 // `PARAVIEW_DEPRECATION_LEVEL` comment so that it can be removed when that
47 // version is finally removed.
48 //----------------------------------------------------------------------------
49 
50 // The level at which warnings should be made.
51 #ifndef PARAVIEW_DEPRECATION_LEVEL
52 // ParaView defaults to deprecation of its current version.
53 #define PARAVIEW_DEPRECATION_LEVEL PARAVIEW_VERSION_NUMBER
54 #endif
55 
56 // API deprecated before 5.10.0 have already been removed.
57 #define PARAVIEW_MINIMUM_DEPRECATION_LEVEL PARAVIEW_VERSION_CHECK(5, 10, 0)
58 
59 // Force the deprecation level to be at least that of ParaView's build
60 // configuration.
61 #if PARAVIEW_DEPRECATION_LEVEL < PARAVIEW_MINIMUM_DEPRECATION_LEVEL
62 #undef PARAVIEW_DEPRECATION_LEVEL
63 #define PARAVIEW_DEPRECATION_LEVEL PARAVIEW_MINIMUM_DEPRECATION_LEVEL
64 #endif
65 
66 // Deprecation macro support for various compilers.
67 #if 0 && __cplusplus >= 201402L
68 // This is currently hard-disabled because compilers do not mix C++ attributes
69 // and `__attribute__` extensions together well.
70 #define PARAVIEW_DEPRECATION(reason) [[deprecated(reason)]]
71 #elif defined(VTK_WRAPPING_CXX)
72 // Ignore deprecation in wrapper code.
73 #define PARAVIEW_DEPRECATION(reason)
74 #elif defined(__VTK_WRAP__)
75 #define PARAVIEW_DEPRECATION(reason) [[vtk::deprecated(reason)]]
76 #else
77 #if defined(_WIN32) || defined(_WIN64)
78 #define PARAVIEW_DEPRECATION(reason) __declspec(deprecated(reason))
79 #elif defined(__clang__)
80 #if __has_extension(attribute_deprecated_with_message)
81 #define PARAVIEW_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
82 #else
83 #define PARAVIEW_DEPRECATION(reason) __attribute__((__deprecated__))
84 #endif
85 #elif defined(__GNUC__)
86 #if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))
87 #define PARAVIEW_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
88 #else
89 #define PARAVIEW_DEPRECATION(reason) __attribute__((__deprecated__))
90 #endif
91 #else
92 #define PARAVIEW_DEPRECATION(reason)
93 #endif
94 #endif
95 
96 // APIs deprecated in the next release.
97 #if defined(__VTK_WRAP__)
98 #define PARAVIEW_DEPRECATED_IN_5_12_0(reason) [[vtk::deprecated(reason, "5.12.0")]]
99 #elif PARAVIEW_DEPRECATION_LEVEL >= PARAVIEW_VERSION_CHECK(5, 12, 0)
100 #define PARAVIEW_DEPRECATED_IN_5_12_0(reason) PARAVIEW_DEPRECATION(reason)
101 #else
102 #define PARAVIEW_DEPRECATED_IN_5_12_0(reason)
103 #endif
104 
105 // APIs deprecated in 5.11.0.
106 #if defined(__VTK_WRAP__)
107 #define PARAVIEW_DEPRECATED_IN_5_11_0(reason) [[vtk::deprecated(reason, "5.11.0")]]
108 #elif PARAVIEW_DEPRECATION_LEVEL >= PARAVIEW_VERSION_CHECK(5, 11, 0)
109 #define PARAVIEW_DEPRECATED_IN_5_11_0(reason) PARAVIEW_DEPRECATION(reason)
110 #else
111 #define PARAVIEW_DEPRECATED_IN_5_11_0(reason)
112 #endif
113 
114 // APIs deprecated in the older release always warn.
115 #if defined(__VTK_WRAP__)
116 #define PARAVIEW_DEPRECATED_IN_5_10_0(reason) [[vtk::deprecated(reason, "5.10.0")]]
117 #else
118 #define PARAVIEW_DEPRECATED_IN_5_10_0(reason) PARAVIEW_DEPRECATION(reason)
119 #endif
120 
121 #endif
122 
123 // VTK-HeaderTest-Exclude: vtkParaViewDeprecation.h