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 "vtkPVVersionQuick.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 …
34 // ```
35 //
36 // Please note the `PARAVIEW_DEPRECATED_IN_` version in the
37 // `PARAVIEW_DEPRECATION_LEVEL` comment so that it can be removed when that
38 // version is finally removed.
39 //----------------------------------------------------------------------------
40 
41 // The level at which warnings should be made.
42 #ifndef PARAVIEW_DEPRECATION_LEVEL
43 // ParaView defaults to deprecation of its current version.
44 #ifdef PARAVIEW_VERSION_NUMBER
45 #define PARAVIEW_DEPRECATION_LEVEL PARAVIEW_VERSION_NUMBER
46 #else
47 #define PARAVIEW_DEPRECATION_LEVEL PARAVIEW_VERSION_NUMBER_QUICK
48 #endif
49 #endif
50 
51 // API deprecated before 6.0.0 have already been removed.
52 #define PARAVIEW_MINIMUM_DEPRECATION_LEVEL PARAVIEW_VERSION_CHECK(6, 0, 0)
53 
54 // Force the deprecation level to be at least that of ParaView's build
55 // configuration.
56 #if PARAVIEW_DEPRECATION_LEVEL < PARAVIEW_MINIMUM_DEPRECATION_LEVEL
57 #undef PARAVIEW_DEPRECATION_LEVEL
58 #define PARAVIEW_DEPRECATION_LEVEL PARAVIEW_MINIMUM_DEPRECATION_LEVEL
59 #endif
60 
61 // Deprecation macro support for various compilers.
62 #if defined(VTK_WRAPPING_CXX)
63 // Ignore deprecation in wrapper code.
64 #define PARAVIEW_DEPRECATION(reason)
65 #elif defined(__VTK_WRAP__)
66 #define PARAVIEW_DEPRECATION(reason) [[vtk::deprecated(reason)]]
67 #else
68 #if defined(__clang__)
69 // Clang 12 and AppleClang 13 and before mix [[deprecated]] with visibility macros, and cause parser
70 // like below error: expected identifier before '__attribute__' class [[deprecated("deprecated")]]
71 // __attribute__((visibility("default"))) Foo {};
72 #if (defined(__apple_build_version__) && (__clang_major__ <= 13))
73 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
74 #elif (__clang_major__ <= 12)
75 #define PARAVIEW_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
76 #else
77 #define PARAVIEW_DEPRECATION(reason) [[deprecated(reason)]]
78 #endif
79 #elif defined(__GNUC__)
80 // GCC 12 and before mix [[deprecated]] with visibility macros, and cause parser like below
81 // error: expected identifier before '__attribute__'
82 // class [[deprecated("deprecated")]] __attribute__((visibility("default"))) Foo {};
83 #if (__GNUC__ <= 12)
84 #define PARAVIEW_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
85 #else
86 #define PARAVIEW_DEPRECATION(reason) [[deprecated(reason)]]
87 #endif
88 #else
89 #define PARAVIEW_DEPRECATION(reason) [[deprecated(reason)]]
90 #endif
91 #endif
92 
93 // APIs deprecated in the next release.
94 #if defined(__VTK_WRAP__)
95 #define PARAVIEW_DEPRECATED_IN_6_2_0(reason) [[vtk::deprecated(reason, "6.2.0")]]
96 #elif PARAVIEW_DEPRECATION_LEVEL >= PARAVIEW_VERSION_CHECK(6, 1, 20260123)
97 #define PARAVIEW_DEPRECATED_IN_6_2_0(reason) PARAVIEW_DEPRECATION(reason)
98 #else
99 #define PARAVIEW_DEPRECATED_IN_6_2_0(reason)
100 #endif
101 
102 // APIs deprecated in 6.1.0.
103 #if defined(__VTK_WRAP__)
104 #define PARAVIEW_DEPRECATED_IN_6_1_0(reason) [[vtk::deprecated(reason, "6.1.0")]]
105 #elif PARAVIEW_DEPRECATION_LEVEL >= PARAVIEW_VERSION_CHECK(6, 0, 20250520)
106 #define PARAVIEW_DEPRECATED_IN_6_1_0(reason) PARAVIEW_DEPRECATION(reason)
107 #else
108 #define PARAVIEW_DEPRECATED_IN_6_1_0(reason)
109 #endif
110 
111 // APIs deprecated in the older release always warn.
112 #if defined(__VTK_WRAP__)
113 #define PARAVIEW_DEPRECATED_IN_6_0_0(reason) [[vtk::deprecated(reason, "6.0.0")]]
114 #define PARAVIEW_DEPRECATED_IN_5_13_0(reason) [[vtk::deprecated(reason, "5.13.0")]]
115 #else
116 #define PARAVIEW_DEPRECATED_IN_6_0_0(reason) PARAVIEW_DEPRECATION(reason)
117 #define PARAVIEW_DEPRECATED_IN_5_13_0(reason) PARAVIEW_DEPRECATION(reason)
118 #endif
119 
120 #endif
121 
122 // VTK-HeaderTest-Exclude: vtkParaViewDeprecation.h