[FFmpeg-cvslog] libavutil: Always use some GCC style attributes on clang

Martin Storsjö git at videolan.org
Thu Feb 2 12:27:57 EET 2017

ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Mon Jul 18 23:25:11 2016 +0300| [f637046d3134a331e4b5a7243ac3dfb92735b8a5] | committer: Martin Storsjö

libavutil: Always use some GCC style attributes on clang

Clang normally disguises as GCC (defining __GNUC__), and thus get
all the normal GCC specific attributes.

Clang can also work as a drop-in replacement for MSVC, and in these
cases, it doesn't define __GNUC__, but defines _MSC_VER instead.

Even in these setups, it still supports the GCC style attributes,
thus use them, especially where there isn't any MSVC specific
version, or where the MSVC specific version doesn't work on clang

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

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

 libavutil/attributes.h | 4 ++--
 libavutil/mem.h        | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavutil/attributes.h b/libavutil/attributes.h
index d7f2bb5..c770f52 100644
--- a/libavutil/attributes.h
+++ b/libavutil/attributes.h
@@ -80,7 +80,7 @@
 #    define attribute_deprecated
-#if defined(__GNUC__)
+#if defined(__GNUC__) || defined(__clang__)
 #    define av_unused __attribute__((unused))
 #    define av_unused
@@ -91,7 +91,7 @@
  * away.  This is useful for variables accessed only from inline
  * assembler without the compiler being aware.
+#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
 #    define av_used __attribute__((used))
 #    define av_used
diff --git a/libavutil/mem.h b/libavutil/mem.h
index 9f667c2..f3cf56c 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -48,7 +48,7 @@
     #define DECLARE_ASM_CONST(n,t,v)                    \
         AV_PRAGMA(DATA_ALIGN(v,n))                      \
         static const t __attribute__((aligned(n))) v
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) || defined(__clang__)
     #define DECLARE_ALIGNED(n,t,v)      t __attribute__ ((aligned (n))) v
     #define DECLARE_ASM_CONST(n,t,v)    static const t av_used __attribute__ ((aligned (n))) v
 #elif defined(_MSC_VER)

More information about the ffmpeg-cvslog mailing list