[vlc-devel] [PATCH 5/6] vlc_common: introduce macro VLC_ATTR

Filip Roséen filip at atch.se
Sun Feb 26 20:13:15 CET 2017


VLC_ATTR is a macro which can be used to annotate an entity with an
attribute. In case the passed attribute is not available under the
current implementation it will simply expand to an empty string.
---
 include/vlc_common.h | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index 6a75753dbf..20eff55f9d 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -93,6 +93,22 @@
 # define VLC_MALLOC __attribute__ ((malloc))
 # define VLC_USED __attribute__ ((warn_unused_result))
 
+# ifdef HAVE_ATTRIBUTE_UNUSED
+#  define VLC_ATTRIBUTE_unused __attribute__((unused))
+# endif
+
+# ifdef HAVE_ATTRIBUTE_NOINLINE
+#  define VLC_ATTRIBUTE_noinline __attribute__((noinline))
+# endif
+
+# ifdef HAVE_ATTRIBUTE_ERROR
+#  define VLC_ATTRIBUTE_error(msg) __attribute__((error( msg )))
+# endif
+
+# ifdef HAVE_ATTRIBUTE_WARNING
+#  define VLC_ATTRIBUTE_warning(msg) __attribute__((warning( msg )))
+# endif
+
 #else
 # define VLC_DEPRECATED
 # define VLC_FORMAT(x,y)
@@ -101,6 +117,23 @@
 # define VLC_USED
 #endif
 
+#ifndef VLC_ATTRIBUTE_unused
+# define VLC_ATTRIBUTE_unused
+#endif
+
+#ifndef VLC_ATTRIBUTE_noinline
+# define VLC_ATTRIBUTE_noinline
+#endif
+
+#ifndef VLC_ATTRIBUTE_warning
+# define VLC_ATTRIBUTE_warning(msg)
+#endif
+
+#ifndef VLC_ATTRIBUTE_error
+# define VLC_ATTRIBUTE_error(msg)
+#endif
+
+#define VLC_ATTR(spec) VLC_ATTRIBUTE_ ## spec
 
 /* Branch prediction */
 #ifdef __GNUC__
-- 
2.11.1



More information about the vlc-devel mailing list