[FFmpeg-cvslog] libavutil: Hook up the rest of the gcc specific attributes to clang as well

Martin Storsjö git at videolan.org
Sat Oct 21 20:26:31 EEST 2017


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Tue Mar 21 14:36:33 2017 +0200| [8e2346154e6d58b733fd20326ce706f82fd91b3e] | committer: Martin Storsjö

libavutil: Hook up the rest of the gcc specific attributes to clang as well

Hook up all attributes that don't have a MSVC specific version at the
moment.

See f637046d313 for details.

These don't seem to be critical for building with clang in MSVC mode
though, and thus haven't been hooked up until now.

These seem to build fine with as old clang as 3.3 at least.
(clang 3.3 disguises itself as gcc 4.2 normally, so all of these
have been used for clang before, except for av_cold.)

The clang version numbers themselves are useless for detecting what
attributes are available, since Apple's clang builds use a completely
different versioning (presenting itself as e.g. clang 8.0 instead
of 3.8).

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8e2346154e6d58b733fd20326ce706f82fd91b3e
---

 libavutil/attributes.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavutil/attributes.h b/libavutil/attributes.h
index cd4e299531..053acd02e6 100644
--- a/libavutil/attributes.h
+++ b/libavutil/attributes.h
@@ -48,19 +48,19 @@
 #    define av_noinline
 #endif
 
-#if AV_GCC_VERSION_AT_LEAST(3,1)
+#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
 #    define av_pure __attribute__((pure))
 #else
 #    define av_pure
 #endif
 
-#if AV_GCC_VERSION_AT_LEAST(2,6)
+#if AV_GCC_VERSION_AT_LEAST(2,6) || defined(__clang__)
 #    define av_const __attribute__((const))
 #else
 #    define av_const
 #endif
 
-#if AV_GCC_VERSION_AT_LEAST(4,3)
+#if AV_GCC_VERSION_AT_LEAST(4,3) || defined(__clang__)
 #    define av_cold __attribute__((cold))
 #else
 #    define av_cold
@@ -97,19 +97,19 @@
 #    define av_used
 #endif
 
-#if AV_GCC_VERSION_AT_LEAST(3,3)
+#if AV_GCC_VERSION_AT_LEAST(3,3) || defined(__clang__)
 #   define av_alias __attribute__((may_alias))
 #else
 #   define av_alias
 #endif
 
-#if defined(__GNUC__) && !defined(__ICC)
+#if (defined(__GNUC__) || defined(__clang__)) && !defined(__ICC)
 #    define av_uninit(x) x=x
 #else
 #    define av_uninit(x) x
 #endif
 
-#ifdef __GNUC__
+#if defined(__GNUC__) || defined(__clang__)
 #    define av_builtin_constant_p __builtin_constant_p
 #    define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
 #else



More information about the ffmpeg-cvslog mailing list