Go to the documentation of this file.
26 #ifndef AVUTIL_ATTRIBUTES_H
27 #define AVUTIL_ATTRIBUTES_H
30 # define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y))
31 # define AV_GCC_VERSION_AT_MOST(x,y) (__GNUC__ < (x) || __GNUC__ == (x) && __GNUC_MINOR__ <= (y))
33 # define AV_GCC_VERSION_AT_LEAST(x,y) 0
34 # define AV_GCC_VERSION_AT_MOST(x,y) 0
38 # define AV_HAS_BUILTIN(x) __has_builtin(x)
40 # define AV_HAS_BUILTIN(x) 0
43 #if defined(__cplusplus) && defined(__has_cpp_attribute)
44 # define AV_HAS_STD_ATTRIBUTE(x) __has_cpp_attribute(x)
45 #elif !defined(__cplusplus) && defined(__has_c_attribute)
46 # define AV_HAS_STD_ATTRIBUTE(x) __has_c_attribute(x)
48 # define AV_HAS_STD_ATTRIBUTE(x) 0
51 #ifndef av_always_inline
52 #if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
53 # define av_always_inline __attribute__((always_inline)) inline
54 #elif defined(_MSC_VER)
55 # define av_always_inline __forceinline
57 # define av_always_inline inline
61 #ifndef av_extern_inline
62 #if defined(__ICL) && __ICL >= 1210 || defined(__GNUC_STDC_INLINE__)
63 # define av_extern_inline extern inline
65 # define av_extern_inline inline
69 #if AV_HAS_STD_ATTRIBUTE(nodiscard)
70 # define av_warn_unused_result [[nodiscard]]
71 #elif AV_GCC_VERSION_AT_LEAST(3,4) || defined(__clang__)
72 # define av_warn_unused_result __attribute__((warn_unused_result))
74 # define av_warn_unused_result
77 #if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
78 # define av_noinline __attribute__((noinline))
79 #elif defined(_MSC_VER)
80 # define av_noinline __declspec(noinline)
85 #if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
86 # define av_pure __attribute__((pure))
91 #if AV_GCC_VERSION_AT_LEAST(2,6) || defined(__clang__)
92 # define av_const __attribute__((const))
97 #if AV_GCC_VERSION_AT_LEAST(4,3) || defined(__clang__)
98 # define av_cold __attribute__((cold))
103 #if AV_GCC_VERSION_AT_LEAST(4,1) && !defined(__llvm__)
104 # define av_flatten __attribute__((flatten))
109 #if AV_HAS_STD_ATTRIBUTE(deprecated)
110 # define attribute_deprecated [[deprecated]]
111 #elif AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
112 # define attribute_deprecated __attribute__((deprecated))
113 #elif defined(_MSC_VER)
114 # define attribute_deprecated __declspec(deprecated)
116 # define attribute_deprecated
124 #ifndef AV_NOWARN_DEPRECATED
125 #if AV_GCC_VERSION_AT_LEAST(4,6) || defined(__clang__)
126 # define AV_NOWARN_DEPRECATED(code) \
127 _Pragma("GCC diagnostic push") \
128 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
130 _Pragma("GCC diagnostic pop")
131 #elif defined(_MSC_VER)
132 # define AV_NOWARN_DEPRECATED(code) \
133 __pragma(warning(push)) \
134 __pragma(warning(disable : 4996)) \
136 __pragma(warning(pop))
138 # define AV_NOWARN_DEPRECATED(code) code
142 #if AV_HAS_STD_ATTRIBUTE(maybe_unused)
143 # define av_unused [[maybe_unused]]
144 #elif defined(__GNUC__) || defined(__clang__)
145 # define av_unused __attribute__((unused))
155 #if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
156 # define av_used __attribute__((used))
161 #if AV_GCC_VERSION_AT_LEAST(3,3) || defined(__clang__)
162 # define av_alias __attribute__((may_alias))
167 #if (defined(__GNUC__) || defined(__clang__)) && !defined(__INTEL_COMPILER)
168 # define av_uninit(x) x=x
170 # define av_uninit(x) x
173 #if defined(__GNUC__) || defined(__clang__)
174 # define av_builtin_constant_p __builtin_constant_p
175 # define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
176 # define av_scanf_format(fmtpos, attrpos) __attribute__((__format__(__scanf__, fmtpos, attrpos)))
178 # define av_builtin_constant_p(x) 0
179 # define av_printf_format(fmtpos, attrpos)
180 # define av_scanf_format(fmtpos, attrpos)
183 #if AV_HAS_STD_ATTRIBUTE(noreturn)
184 # define av_noreturn [[noreturn]]
185 #elif AV_GCC_VERSION_AT_LEAST(2,5) || defined(__clang__)
186 # define av_noreturn __attribute__((noreturn))