VTK  9.4.20241108
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_9_1_0() warnings for this class.
35// #define VTK_DEPRECATION_LEVEL 0
36//
37// #include "vtkLegacy.h"
38//
39// void oldApi()
40// {
41// // One of:
42// VTK_LEGACY_BODY(oldApi, "VTK 9.1");
43// VTK_LEGACY_REPLACED_BODY(oldApi, "VTK 9.1", newApi);
44//
45// // Remaining implementation.
46// }
47// ```
48//
49// Please note the `VTK_DEPRECATED_IN_` version in the `VTK_DEPRECATION_LEVEL`
50// comment so that it can be removed when that version is finally removed.
51//----------------------------------------------------------------------------
52
53// The level at which warnings should be made.
54#ifndef VTK_DEPRECATION_LEVEL
55// VTK defaults to deprecation of its current version.
56#ifdef VTK_VERSION_NUMBER
57#define VTK_DEPRECATION_LEVEL VTK_VERSION_NUMBER
58#else
59#define VTK_DEPRECATION_LEVEL VTK_VERSION_NUMBER_QUICK
60#endif
61#endif
62
63// API deprecated before 9.1.0 have already been removed.
64#define VTK_MINIMUM_DEPRECATION_LEVEL VTK_VERSION_CHECK(9, 1, 0)
65
66// Force the deprecation level to be at least that of VTK's build
67// configuration.
68#if VTK_DEPRECATION_LEVEL < VTK_MINIMUM_DEPRECATION_LEVEL
69#undef VTK_DEPRECATION_LEVEL
70#define VTK_DEPRECATION_LEVEL VTK_MINIMUM_DEPRECATION_LEVEL
71#endif
72
73// Deprecation macro support for various compilers.
74#if 0 && __cplusplus >= 201402L
75// This is currently hard-disabled because compilers do not mix C++ attributes
76// and `__attribute__` extensions together well.
77#define VTK_DEPRECATION(reason) [[deprecated(reason)]]
78#elif defined(VTK_WRAPPING_CXX)
79// Ignore deprecation in wrapper code.
80#define VTK_DEPRECATION(reason)
81#elif defined(__VTK_WRAP__)
82#define VTK_DEPRECATION(reason) [[vtk::deprecated(reason)]]
83#else
84#if defined(_WIN32) || defined(_WIN64)
85#define VTK_DEPRECATION(reason) __declspec(deprecated(reason))
86#elif defined(__clang__)
87#if __has_extension(attribute_deprecated_with_message)
88#define VTK_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
89#else
90#define VTK_DEPRECATION(reason) __attribute__((__deprecated__))
91#endif
92#elif defined(__GNUC__)
93#if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))
94#define VTK_DEPRECATION(reason) __attribute__((__deprecated__(reason)))
95#else
96#define VTK_DEPRECATION(reason) __attribute__((__deprecated__))
97#endif
98#else
99#define VTK_DEPRECATION(reason)
100#endif
101#endif
102
103// APIs deprecated in the next release.
104#if defined(__VTK_WRAP__)
105#define VTK_DEPRECATED_IN_9_4_0(reason) [[vtk::deprecated(reason, "9.4.0")]]
106#elif VTK_DEPRECATION_LEVEL >= VTK_VERSION_CHECK(9, 3, 20230807)
107#define VTK_DEPRECATED_IN_9_4_0(reason) VTK_DEPRECATION(reason)
108#else
109#define VTK_DEPRECATED_IN_9_4_0(reason)
110#endif
111
112// APIs deprecated in 9.3.0.
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 the older release always warn.
122#if defined(__VTK_WRAP__)
123#define VTK_DEPRECATED_IN_9_2_0(reason) [[vtk::deprecated(reason, "9.2.0")]]
124#else
125#define VTK_DEPRECATED_IN_9_2_0(reason) VTK_DEPRECATION(reason)
126#endif
127
128#if defined(__VTK_WRAP__)
129#define VTK_DEPRECATED_IN_9_1_0(reason) [[vtk::deprecated(reason, "9.1.0")]]
130#else
131#define VTK_DEPRECATED_IN_9_1_0(reason) VTK_DEPRECATION(reason)
132#endif
133
134#if defined(__VTK_WRAP__)
135#define VTK_DEPRECATED_IN_9_0_0(reason) [[vtk::deprecated(reason, "9.0.0")]]
136#else
137#define VTK_DEPRECATED_IN_9_0_0(reason) VTK_DEPRECATION(reason)
138#endif
139
140#if defined(__VTK_WRAP__)
141#define VTK_DEPRECATED_IN_8_2_0(reason) [[vtk::deprecated(reason, "8.2.0")]]
142#else
143#define VTK_DEPRECATED_IN_8_2_0(reason) VTK_DEPRECATION(reason)
144#endif
145
146#endif
147
148// VTK-HeaderTest-Exclude: vtkDeprecation.h