From d1b533d399df7bbd686ecb2289c08e4ef8fd1ba4 Mon Sep 17 00:00:00 2001 From: Yuriy Chernyshov Date: Mon, 24 Jan 2022 11:23:34 +0300 Subject: [PATCH] Disable -Wreturn-type-c-linkage under clang-cl clang-cl defines both __clang__ and _MSC_VER, yet uses `#pragma GCC` to disable certain diagnostics. At the time `-Wreturn-type-c-linkage` was reported by clang-cl. This PR fixes this behavior by reordering defines. --- modules/core/include/opencv2/core/core_c.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/core/include/opencv2/core/core_c.h b/modules/core/include/opencv2/core/core_c.h index 95a98cfcd0..76141be80a 100644 --- a/modules/core/include/opencv2/core/core_c.h +++ b/modules/core/include/opencv2/core/core_c.h @@ -48,16 +48,19 @@ #include "opencv2/core/types_c.h" #ifdef __cplusplus -# ifdef _MSC_VER -/* disable warning C4190: 'function' has C-linkage specified, but returns UDT 'typename' - which is incompatible with C +/* disable MSVC warning C4190 / clang-cl -Wreturn-type-c-linkage: + 'function' has C-linkage specified, but returns UDT 'typename' + which is incompatible with C It is OK to disable it because we only extend few plain structures with C++ constructors for simpler interoperability with C++ API of the library */ -# pragma warning(disable:4190) -# elif defined __clang__ && __clang_major__ >= 3 +# if defined(__clang__) + // handle clang on Linux and clang-cl (i. e. clang on Windows) first # pragma GCC diagnostic ignored "-Wreturn-type-c-linkage" +# elif defined(_MSC_VER) + // then handle MSVC +# pragma warning(disable:4190) # endif #endif