From patchwork Fri Feb 9 22:05:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Le Cuirot X-Patchwork-Id: 99054 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from sv.mirrors.kernel.org ([139.178.88.99]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rYZ1i-00006C-2S for patchwork@linuxtv.org; Fri, 09 Feb 2024 22:07:19 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E65C728300C for ; Fri, 9 Feb 2024 22:07:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8934D21344; Fri, 9 Feb 2024 22:07:14 +0000 (UTC) X-Original-To: linux-media@vger.kernel.org Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3E53182D2 for ; Fri, 9 Feb 2024 22:07:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.211.166.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707516434; cv=none; b=upND9zCnypmEkMGk+jtPOAzERph1LcS/HZBWhgFvKuYdnwX/cRmZYgpnEOXH1Hz+3ag44xwD6KKNw+T9XWkXQipm7wFpDTKgKVD0IabgPZ3AYyfz6Fz2FCn9kuObXvKzNO8i6c4sRvlpCDXALZ5qseEO6/okllOkPs8MU+Zu6uY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707516434; c=relaxed/simple; bh=z01e7mxHy9zypXf1tuvq6cFqkV1th2z3tF0uerhFCF8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=s4lJadIRvT87bVsRvtNZ0/ZntaN+7GqHtIn50adhVdiijMvBzfXVbts9z2aP7ZjbtJ/OlLwuKjCDPWECrBHexKYsR9zfTk0POtRjfNMQmb6F62zto0yYJYaVxRXZ9KZLWQQbPW58TGxE5adhl3ISqaSIS0pJFknzqfGlCRCkRtI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gentoo.org; spf=pass smtp.mailfrom=gentoo.org; arc=none smtp.client-ip=140.211.166.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gentoo.org From: James Le Cuirot To: linux-media@vger.kernel.org Cc: James Le Cuirot Subject: [PATCH v2] v4l2-compliance: Fix building against libc++ Date: Fri, 9 Feb 2024 22:05:29 +0000 Message-ID: <20240209220601.18704-2-chewi@gentoo.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-LSpam-Score: -2.0 (--) X-LSpam-Report: No, score=-2.0 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,DMARC_NONE=0.898,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no v4l2-test-time32-64.cpp included compiler.h, which checks _LIBCPP_VERSION. This only works against libc++ when a C++ header has already been included, which wasn't the case here. The header is the C++20 method of defining _LIBCPP_VERSION, but for older versions, works as an alternative, so include that in compiler.h. compiler.h is for C as well as C++ though, so use __cplusplus to check for a C++ compiler before including . Signed-off-by: James Le Cuirot --- include/compiler.h | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) -- 2.43.0 diff --git a/include/compiler.h b/include/compiler.h index 5ad54f41..169247a8 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -1,17 +1,14 @@ -#ifdef _LIBCPP_VERSION -#define fallthrough _LIBCPP_FALLTHROUGH() +#if !defined(__cplusplus) || __cplusplus < 201103L + #define fallthrough ((void)0) #else - -#if __cplusplus >= 201103L - -#ifdef __clang__ -#define fallthrough [[clang::fallthrough]] -#else -#define fallthrough [[gnu::fallthrough]] -#endif // __clang__ - -#else -#define fallthrough ((void)0) - + #include + #ifdef _LIBCPP_VERSION + #define fallthrough _LIBCPP_FALLTHROUGH() + #else + #ifdef __clang__ + #define fallthrough [[clang::fallthrough]] + #else + #define fallthrough [[gnu::fallthrough]] + #endif // __clang__ + #endif // _LIBCPP_VERSION #endif // __cplusplus -#endif // _LIBCPP_VERSION