VTK  9.4.20250221
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// or
24// ```cxx
25// class VTK_DEPRECATED_IN_X_Y_Z("reason for deprecation") OPT_EXPORT_MACRO oldClass {
26// ```
27//
28// When selecting which version to deprecate an API in, use the newest macro
29// available in this header.
30//
31// In the implementation:
32//
33// ```cxx
34// // Hide VTK_DEPRECATED_IN_X_Y_Z() warnings for this class.
35// #define VTK_DEPRECATION_LEVEL 0
36//
37// #include …
38// ```
39//
40// Please note the `VTK_DEPRECATED_IN_` version in the `VTK_DEPRECATION_LEVEL`
41// comment so that it can be removed when that version is finally removed. The
42// macro should also be defined before any includes.
43//----------------------------------------------------------------------------
44
45// The level at which warnings should be made.
46#ifndef VTK_DEPRECATION_LEVEL
47// VTK defaults to deprecation of its current version.
48#ifdef VTK_VERSION_NUMBER
49#define VTK_DEPRECATION_LEVEL VTK_VERSION_NUMBER
50#else
51#define VTK_DEPRECATION_LEVEL VTK_VERSION_NUMBER_QUICK
52#endif
53#endif
54
55// API deprecated before 9.3.0 have already been removed.
56#define VTK_MINIMUM_DEPRECATION_LEVEL VTK_VERSION_CHECK(9, 3, 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_5_0(reason) [[vtk::deprecated(reason, "9.5.0")]]
98#elif VTK_DEPRECATION_LEVEL >= VTK_VERSION_CHECK(9, 4, 20241008)
99#define VTK_DEPRECATED_IN_9_5_0(reason) VTK_DEPRECATION(reason)
100#else
101#define VTK_DEPRECATED_IN_9_5_0(reason)
102#endif
103
104// APIs deprecated in 9.4.0.
105#if defined(__VTK_WRAP__)
106#define VTK_DEPRECATED_IN_9_4_0(reason) [[vtk::deprecated(reason, "9.4.0")]]
107#elif VTK_DEPRECATION_LEVEL >= VTK_VERSION_CHECK(9, 3, 20230807)
108#define VTK_DEPRECATED_IN_9_4_0(reason) VTK_DEPRECATION(reason)
109#else
110#define VTK_DEPRECATED_IN_9_4_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_3_0(reason) [[vtk::deprecated(reason, "9.3.0")]]
116#else
117#define VTK_DEPRECATED_IN_9_3_0(reason) VTK_DEPRECATION(reason)
118#endif
119
120#if defined(__VTK_WRAP__)
121#define VTK_DEPRECATED_IN_9_2_0(reason) [[vtk::deprecated(reason, "9.2.0")]]
122#else
123#define VTK_DEPRECATED_IN_9_2_0(reason) VTK_DEPRECATION(reason)
124#endif
125
126#if defined(__VTK_WRAP__)
127#define VTK_DEPRECATED_IN_9_1_0(reason) [[vtk::deprecated(reason, "9.1.0")]]
128#else
129#define VTK_DEPRECATED_IN_9_1_0(reason) VTK_DEPRECATION(reason)
130#endif
131
132#if defined(__VTK_WRAP__)
133#define VTK_DEPRECATED_IN_9_0_0(reason) [[vtk::deprecated(reason, "9.0.0")]]
134#else
135#define VTK_DEPRECATED_IN_9_0_0(reason) VTK_DEPRECATION(reason)
136#endif
137
138#if defined(__VTK_WRAP__)
139#define VTK_DEPRECATED_IN_8_2_0(reason) [[vtk::deprecated(reason, "8.2.0")]]
140#else
141#define VTK_DEPRECATED_IN_8_2_0(reason) VTK_DEPRECATION(reason)
142#endif
143
144#endif
145
146// VTK-HeaderTest-Exclude: vtkDeprecation.h