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 "vtkVersion.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 #include "vtkVersionMacros.h" 70 #define VTK_DEPRECATION_LEVEL VTK_VERSION_NUMBER 71 #endif 72 73 // API deprecated before 8.2.0 have already been removed. 74 #define VTK_MINIMUM_DEPRECATION_LEVEL VTK_VERSION_CHECK(8, 2, 0) 75 76 // Force the deprecation level to be at least that of VTK's build 77 // configuration. 78 #if VTK_DEPRECATION_LEVEL < VTK_MINIMUM_DEPRECATION_LEVEL 79 #undef VTK_DEPRECATION_LEVEL 80 #define VTK_DEPRECATION_LEVEL VTK_MINIMUM_DEPRECATION_LEVEL 81 #endif 82 83 // Deprecation macro support for various compilers. 84 #if 0 && __cplusplus >= 201402L 85 // This is currently hard-disabled because compilers do not mix C++ attributes 86 // and `__attribute__` extensions together well. 87 #define VTK_DEPRECATION(reason) [[deprecated(reason)]] 88 #elif defined(VTK_WRAPPING_CXX) 89 // Ignore deprecation in wrapper code. 90 #define VTK_DEPRECATION(reason) 91 #elif defined(__VTK_WRAP__) 92 #define VTK_DEPRECATION(reason) [[vtk::deprecated(reason)]] 93 #else 94 #if defined(_WIN32) || defined(_WIN64) 95 #define VTK_DEPRECATION(reason) __declspec(deprecated(reason)) 96 #elif defined(__clang__) 97 #if __has_extension(attribute_deprecated_with_message) 98 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__(reason))) 99 #else 100 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__)) 101 #endif 102 #elif defined(__GNUC__) 103 #if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) 104 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__(reason))) 105 #else 106 #define VTK_DEPRECATION(reason) __attribute__((__deprecated__)) 107 #endif 108 #else 109 #define VTK_DEPRECATION(reason) 110 #endif 111 #endif 112 113 // APIs deprecated in the next release. 114 #if defined(__VTK_WRAP__) 115 #define VTK_DEPRECATED_IN_9_1_0(reason) [[vtk::deprecated(reason, "9.1.0")]] 116 #elif VTK_DEPRECATION_LEVEL >= VTK_VERSION_CHECK(9, 1, 0) 117 #define VTK_DEPRECATED_IN_9_1_0(reason) VTK_DEPRECATION(reason) 118 #else 119 #define VTK_DEPRECATED_IN_9_1_0(reason) 120 #endif 121 122 // APIs deprecated in 9.0.0. 123 #if defined(__VTK_WRAP__) 124 #define VTK_DEPRECATED_IN_9_0_0(reason) [[vtk::deprecated(reason, "9.0.0")]] 125 #elif VTK_DEPRECATION_LEVEL >= VTK_VERSION_CHECK(9, 0, 0) 126 #define VTK_DEPRECATED_IN_9_0_0(reason) VTK_DEPRECATION(reason) 127 #else 128 #define VTK_DEPRECATED_IN_9_0_0(reason) 129 #endif 130 131 // APIs deprecated in the older release always warn. 132 #if defined(__VTK_WRAP__) 133 #define VTK_DEPRECATED_IN_8_2_0(reason) [[vtk::deprecated(reason, "8.2.0")]] 134 #else 135 #define VTK_DEPRECATED_IN_8_2_0(reason) VTK_DEPRECATION(reason) 136 #endif 137 138 #endif 139 140 // VTK-HeaderTest-Exclude: vtkDeprecation.h 141