[vlc-devel] [PATCH 2/4] vlc_common.h: Split __has_attribute in a different directive

Hugo Beauzée-Luyssen hugo at beauzee.fr
Thu Oct 22 09:49:47 CEST 2020


Once we know that we are using clang, we can use __has_attribute. Doing
so in a single directive confuses some compilers (in this case, MSVC)
---
 include/vlc_common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index 22a6c089d7..323df74653 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -559,11 +559,13 @@ static inline size_t vlc_align(size_t v, size_t align)
     return (v + (align - 1)) & ~(align - 1);
 }
 
-#if defined(__clang__) && __has_attribute(diagnose_if)
+#if defined(__clang__)
+#if __has_attribute(diagnose_if)
 static inline size_t vlc_align(size_t v, size_t align)
     __attribute__((diagnose_if(((align & (align - 1)) || (align == 0)),
         "align must be power of 2", "error")));
 #endif
+#endif
 
 /** Greatest common divisor */
 VLC_USED
-- 
2.20.1



More information about the vlc-devel mailing list