From b0470f8e1a8df73490a4ed905cfba97acb82212b Mon Sep 17 00:00:00 2001 From: Alexander Lobakin Date: Mon, 23 Mar 2026 18:44:09 +0100 Subject: [PATCH] Fix compilation with ClangCL and AVX2 Both __builtin_sadd_overflow() and __builtin_ctz() are available in Clang even when building under Visual Studio, define them only when compiling with MSVC to fix the following error: opus\silk\x86\NSQ_del_dec_avx2.c(81,19): warning : redeclaring non-static '__builtin_ctz' as static is a Microsoft extension [-Wmicrosoft-redeclare-static] 81 | static inline int __builtin_ctz(unsigned int x) | ^ C:\Program Files\LLVM\lib\clang\22\include\ia32intrin.h(43,10): note: '__builtin_ctz' is a builtin with type 'int (unsigned int)' 43 | return __builtin_ctz((unsigned int)__A); | ^ opus\silk\x86\NSQ_del_dec_avx2.c(81,19): error : definition of builtin function '__builtin_ctz' 81 | static inline int __builtin_ctz(unsigned int x) | ^ 1 warning and 1 error generated. Signed-off-by: Alexander Lobakin --- silk/x86/NSQ_del_dec_avx2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/silk/x86/NSQ_del_dec_avx2.c b/silk/x86/NSQ_del_dec_avx2.c index 02038fced..a881ef212 100644 --- a/silk/x86/NSQ_del_dec_avx2.c +++ b/silk/x86/NSQ_del_dec_avx2.c @@ -71,7 +71,7 @@ static OPUS_INLINE int verify_assumptions(const silk_encoder_state *psEncC) } /* Intrinsics not defined on MSVC */ -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #include static inline int __builtin_sadd_overflow(opus_int32 a, opus_int32 b, opus_int32* res) {