Loading...
Searching...
No Matches
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
44# define AV_HAS_ATTRIBUTE(x) __has_attribute(x)
46# define AV_HAS_ATTRIBUTE(x) 0
49#if defined(__cplusplus) && \
50 defined(__has_cpp_attribute) && \
51 __cplusplus >= 201103L
52# define AV_HAS_STD_ATTRIBUTE(x) __has_cpp_attribute(x)
53#elif !defined(__cplusplus) && \
54 defined(__has_c_attribute) && \
55 defined(__STDC_VERSION__) && \
56 __STDC_VERSION__ >= 202311L
57# define AV_HAS_STD_ATTRIBUTE(x) __has_c_attribute(x)
59# define AV_HAS_STD_ATTRIBUTE(x) 0
62#if AV_HAS_STD_ATTRIBUTE(fallthrough)
63# define av_fallthrough [[fallthrough]]
64#elif AV_HAS_ATTRIBUTE(fallthrough)
65# define av_fallthrough __attribute__((fallthrough))
67# define av_fallthrough do {} while(0)
70#ifndef av_always_inline
71#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
72# define av_always_inline __attribute__((always_inline)) inline
73#elif defined(_MSC_VER)
74# define av_always_inline __forceinline
76# define av_always_inline inline
80#ifndef av_extern_inline
81#if defined(__ICL) && __ICL >= 1210 || defined(__GNUC_STDC_INLINE__)
82# define av_extern_inline extern inline
84# define av_extern_inline inline
88#if AV_HAS_STD_ATTRIBUTE(nodiscard)
89# define av_warn_unused_result [[nodiscard]]
90#elif AV_GCC_VERSION_AT_LEAST(3,4) || defined(__clang__)
91# define av_warn_unused_result __attribute__((warn_unused_result))
93# define av_warn_unused_result
96#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
97# define av_noinline __attribute__((noinline))
98#elif defined(_MSC_VER)
99# define av_noinline __declspec(noinline)
104#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
105# define av_pure __attribute__((pure))
110#if AV_GCC_VERSION_AT_LEAST(2,6) || defined(__clang__)
111# define av_const __attribute__((const))
116#if AV_GCC_VERSION_AT_LEAST(4,3) || defined(__clang__)
117# define av_cold __attribute__((cold))
122#if (AV_GCC_VERSION_AT_LEAST(4,1) && !defined(__clang__ )) || AV_HAS_ATTRIBUTE(flatten)
123# define av_flatten __attribute__((flatten))
128#if AV_HAS_STD_ATTRIBUTE(deprecated)
129# define attribute_deprecated [[deprecated]]
130#elif AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
131# define attribute_deprecated __attribute__((deprecated))
132#elif defined(_MSC_VER)
133# define attribute_deprecated __declspec(deprecated)
135# define attribute_deprecated
143#ifndef AV_NOWARN_DEPRECATED
144#if AV_GCC_VERSION_AT_LEAST(4,6) || defined(__clang__)
145# define AV_NOWARN_DEPRECATED(code) \
146 _Pragma("GCC diagnostic push") \
147 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
149 _Pragma("GCC diagnostic pop")
150#elif defined(_MSC_VER)
151# define AV_NOWARN_DEPRECATED(code) \
152 __pragma(warning(push)) \
153 __pragma(warning(disable : 4996)) \
155 __pragma(warning(pop))
157# define AV_NOWARN_DEPRECATED(code) code
161#if AV_HAS_STD_ATTRIBUTE(maybe_unused)
162# define av_unused [[maybe_unused]]
163#elif defined(__GNUC__) || defined(__clang__)
164# define av_unused __attribute__((unused))
174#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
175# define av_used __attribute__((used))
180#if AV_GCC_VERSION_AT_LEAST(3,3) || defined(__clang__)
181# define av_alias __attribute__((may_alias))
186#if (defined(__GNUC__) || defined(__clang__)) && !defined(__INTEL_COMPILER)
187# define av_uninit(x) x=x
189# define av_uninit(x) x
192#if defined(__GNUC__) || defined(__clang__)
193# define av_builtin_constant_p __builtin_constant_p
195# define av_builtin_constant_p(x) 0
203#ifdef __MINGW_PRINTF_FORMAT
204# define AV_PRINTF_FMT __MINGW_PRINTF_FORMAT
205#elif AV_HAS_ATTRIBUTE(format)
206# define AV_PRINTF_FMT __printf__
209#ifdef __MINGW_SCANF_FORMAT
210# define AV_SCANF_FMT __MINGW_SCANF_FORMAT
211#elif AV_HAS_ATTRIBUTE(format)
212# define AV_SCANF_FMT __scanf__
216# define av_printf_format(fmtpos, attrpos) __attribute__((format(AV_PRINTF_FMT, fmtpos, attrpos)))
218# define av_printf_format(fmtpos, attrpos)
222# define av_scanf_format(fmtpos, attrpos) __attribute__((format(AV_SCANF_FMT, fmtpos, attrpos)))
224# define av_scanf_format(fmtpos, attrpos)
227#if AV_HAS_STD_ATTRIBUTE(noreturn)
228# define av_noreturn [[noreturn]]
229#elif AV_GCC_VERSION_AT_LEAST(2,5) || defined(__clang__)
230# define av_noreturn __attribute__((noreturn))