1 /* 2 * API versioning definitions for CUPS. 3 * 4 * Copyright 2007-2016 by Apple Inc. 5 * 6 * These coded instructions, statements, and computer programs are the 7 * property of Apple Inc. and are protected by Federal copyright 8 * law. Distribution and use rights are outlined in the file "LICENSE.txt" 9 * which should have been included with this file. If this file is 10 * missing or damaged, see the license at "http://www.cups.org/". 11 * 12 * This file is subject to the Apple OS-Developed Software exception. 13 */ 14 15 #ifndef _CUPS_VERSIONING_H_ 16 # define _CUPS_VERSIONING_H_ 17 18 /* 19 * This header defines several constants - _CUPS_DEPRECATED, 20 * _CUPS_DEPRECATED_MSG, _CUPS_INTERNAL_MSG, _CUPS_API_1_1, _CUPS_API_1_1_19, 21 * _CUPS_API_1_1_20, _CUPS_API_1_1_21, _CUPS_API_1_2, _CUPS_API_1_3, 22 * _CUPS_API_1_4, _CUPS_API_1_5, _CUPS_API_1_6, _CUPS_API_1_7, and 23 * _CUPS_API_2_0 - which add compiler-specific attributes that flag functions 24 * that are deprecated, added in particular releases, or internal to CUPS. 25 * 26 * On macOS, the _CUPS_API_* constants are defined based on the values of 27 * the MAC_OS_X_VERSION_MIN_ALLOWED and MAC_OS_X_VERSION_MAX_ALLOWED constants 28 * provided by the compiler. 29 */ 30 31 # if defined(__APPLE__) && !defined(_CUPS_SOURCE) && !TARGET_OS_IOS 32 # include <AvailabilityMacros.h> 33 # ifndef AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER 34 # define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER __attribute__((unavailable)) 35 # endif /* !AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER */ 36 # ifndef AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER 37 # define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER __attribute__((unavailable)) 38 # endif /* !AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER */ 39 # ifndef AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER 40 # define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER __attribute__((unavailable)) 41 # endif /* !AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER */ 42 # ifndef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER 43 # define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER __attribute__((unavailable)) 44 # endif /* !AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER */ 45 # ifndef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER 46 # define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER __attribute__((unavailable)) 47 # endif /* !AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER */ 48 # ifndef AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER 49 # define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER __attribute__((unavailable)) 50 # endif /* !AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER */ 51 # ifndef AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER 52 # define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER __attribute__((unavailable)) 53 # endif /* !AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER */ 54 # ifndef AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER 55 # define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER __attribute__((unavailable)) 56 # endif /* !AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER */ 57 # ifndef AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER 58 # define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER __attribute__((unavailable)) 59 # endif /* !AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER */ 60 # define _CUPS_API_1_1_19 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER 61 # define _CUPS_API_1_1_20 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER 62 # define _CUPS_API_1_1_21 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER 63 # define _CUPS_API_1_2 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER 64 # define _CUPS_API_1_3 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER 65 # define _CUPS_API_1_4 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER 66 # define _CUPS_API_1_5 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER 67 # define _CUPS_API_1_6 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER 68 # define _CUPS_API_1_7 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER 69 # define _CUPS_API_2_0 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER 70 # define _CUPS_API_2_2 AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER 71 # else 72 # define _CUPS_API_1_1_19 73 # define _CUPS_API_1_1_20 74 # define _CUPS_API_1_1_21 75 # define _CUPS_API_1_2 76 # define _CUPS_API_1_3 77 # define _CUPS_API_1_4 78 # define _CUPS_API_1_5 79 # define _CUPS_API_1_6 80 # define _CUPS_API_1_7 81 # define _CUPS_API_2_0 82 # define _CUPS_API_2_2 83 # endif /* __APPLE__ && !_CUPS_SOURCE */ 84 85 /* 86 * With GCC and Clang we can mark old APIs as "deprecated" or "unavailable" with 87 * messages so you get warnings/errors are compile-time... 88 */ 89 90 # ifdef __has_extension /* Clang */ 91 # define _CUPS_HAS_DEPRECATED 92 # if __has_extension(attribute_deprecated_with_message) 93 # define _CUPS_HAS_DEPRECATED_WITH_MESSAGE 94 # endif 95 # if __has_extension(attribute_unavailable_with_message) 96 # define _CUPS_HAS_UNAVAILABLE_WITH_MESSAGE 97 # endif 98 # elif defined(__GNUC__) /* GCC and compatible */ 99 # if __GNUC__ >= 3 /* GCC 3.0 or higher */ 100 # define _CUPS_HAS_DEPRECATED 101 # endif /* __GNUC__ >= 3 */ 102 # if __GNUC__ >= 5 /* GCC 5.x */ 103 # define _CUPS_HAS_DEPRECATED_WITH_MESSAGE 104 # elif __GNUC__ == 4 && __GNUC_MINOR__ >= 5 105 /* GCC 4.5 or higher */ 106 # define _CUPS_HAS_DEPRECATED_WITH_MESSAGE 107 # endif /* __GNUC__ >= 5 */ 108 # endif /* __has_extension */ 109 110 # if !defined(_CUPS_HAS_DEPRECATED) || (defined(_CUPS_SOURCE) && !defined(_CUPS_NO_DEPRECATED)) 111 /* 112 * Don't mark functions deprecated if the compiler doesn't support it 113 * or we are building CUPS source that doesn't care. 114 */ 115 # define _CUPS_DEPRECATED 116 # define _CUPS_DEPRECATED_MSG(m) 117 # define _CUPS_DEPRECATED_1_6_MSG(m) 118 # define _CUPS_DEPRECATED_1_7_MSG(m) 119 # define _CUPS_INTERNAL_MSG(m) 120 # elif defined(_CUPS_HAS_UNAVAILABLE_WITH_MESSAGE) && defined(_CUPS_NO_DEPRECATED) 121 /* 122 * Compiler supports the unavailable attribute, so use it when the code 123 * wants to exclude the use of deprecated API. 124 */ 125 # define _CUPS_DEPRECATED __attribute__ ((unavailable)) 126 # define _CUPS_DEPRECATED_MSG(m) __attribute__ ((unavailable(m))) 127 # define _CUPS_DEPRECATED_1_6_MSG(m) __attribute__ ((unavailable(m))) 128 # define _CUPS_DEPRECATED_1_7_MSG(m) __attribute__ ((unavailable(m))) 129 # define _CUPS_INTERNAL_MSG(m) __attribute__ ((unavailable(m))) 130 # else 131 /* 132 * Compiler supports the deprecated attribute, so use it. 133 */ 134 # define _CUPS_DEPRECATED __attribute__ ((deprecated)) 135 # ifdef _CUPS_HAS_DEPRECATED_WITH_MESSAGE 136 # define _CUPS_DEPRECATED_MSG(m) __attribute__ ((deprecated(m))) 137 # else 138 # define _CUPS_DEPRECATED_MSG(m) __attribute__ ((deprecated)) 139 # endif /* _CUPS_HAS_DEPRECATED_WITH_MESSAGE */ 140 # if defined(MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 141 # define _CUPS_DEPRECATED_1_6_MSG(m) _CUPS_DEPRECATED_MSG(m) 142 # else 143 # define _CUPS_DEPRECATED_1_6_MSG(m) 144 # endif /* MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_8 */ 145 # if defined(MAC_OS_X_VERSION_10_9) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 146 # define _CUPS_DEPRECATED_1_7_MSG(m) _CUPS_DEPRECATED_MSG(m) 147 # else 148 # define _CUPS_DEPRECATED_1_7_MSG(m) 149 # endif /* MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9 */ 150 # ifdef _CUPS_SOURCE 151 # define _CUPS_INTERNAL_MSG(m) 152 # elif defined(_CUPS_HAS_UNAVAILABLE_WITH_MESSAGE) 153 # define _CUPS_INTERNAL_MSG(m) __attribute__ ((unavailable(m))) 154 # elif defined(_CUPS_HAS_DEPRECATED_WITH_MESSAGE) 155 # define _CUPS_INTERNAL_MSG(m) __attribute__ ((deprecated(m))) 156 # else 157 # define _CUPS_INTERNAL_MSG(m) __attribute__ ((deprecated)) 158 # endif /* _CUPS_SOURCE */ 159 # endif /* !_CUPS_HAS_DEPRECATED || (_CUPS_SOURCE && !_CUPS_NO_DEPRECATED) */ 160 161 # ifndef __GNUC__ 162 # define __attribute__(x) 163 # endif /* !__GNUC__ */ 164 165 #endif /* !_CUPS_VERSIONING_H_ */ 166