From patchwork Sat Aug 22 20:04:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 9372 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4E754BE173 for ; Sat, 22 Aug 2020 20:05:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BF879626DB; Sat, 22 Aug 2020 22:05:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ECKSTAWC"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2CDF761EA0 for ; Sat, 22 Aug 2020 22:05:16 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ACA2629E for ; Sat, 22 Aug 2020 22:05:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1598126715; bh=LV0PC2vjP2bm4mlu2haMklg6jsDQ3ACTy1KSfV85WJE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ECKSTAWCPEKZx2KQCN9kOjtYa6k7w7biISJPC92Crs/1soTCCpydWjohRrRlGqn/1 8e2w/G2wcE5YY/2mNI7FfxK5dcRSS0jxyX+LzbRWQr30AT35o7dWpjE2WgoCDYDGuG IpENv+gy+Lnqulfb5Pp5t6CbFq9ohBDOktj8Pubo= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 22 Aug 2020 23:04:54 +0300 Message-Id: <20200822200454.21718-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200822200037.20892-2-laurent.pinchart@ideasonboard.com> References: <20200822200037.20892-2-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1.1 1/5] meson: Switch to C++17 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Due to popular request, move from C++14 to C++17. This will allow dropping some custom constructs (such as a custom utils::clamp), benefiting from new language features, and dropping gcc 5 and 6 from the compilation tests. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- Changes since v1: - Update documentation - Print an error message when detecting a too old compiler --- Documentation/coding-style.rst | 5 ++--- meson.build | 29 ++++++++++++++++++----------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Documentation/coding-style.rst b/Documentation/coding-style.rst index 7acba37b8de8..7c56a1b70014 100644 --- a/Documentation/coding-style.rst +++ b/Documentation/coding-style.rst @@ -88,13 +88,12 @@ headers, and with double quotes for other libcamera headers. C++ Specific Rules ------------------ -The code shall be implemented in C++14, with the following caveats: +The code shall be implemented in C++17, with the following caveats: * Type inference (auto and decltype) shall be used with caution, to avoid drifting towards an untyped language. * The explicit, override and final specifiers are to be used where applicable. -* General-purpose smart pointers (std::unique_ptr) deprecate std::auto_ptr. - Smart pointers, as well as shared pointers and weak pointers, shall not be +* Smart pointers, as well as shared pointers and weak pointers, shall not be overused. * Classes are encouraged to define move constructors and assignment operators where applicable, and generally make use of the features offered by rvalue diff --git a/meson.build b/meson.build index ec54e68f3635..cf2636d97100 100644 --- a/meson.build +++ b/meson.build @@ -6,7 +6,7 @@ project('libcamera', 'c', 'cpp', default_options : [ 'werror=true', 'warning_level=2', - 'cpp_std=c++14', + 'cpp_std=c++17', ], license : 'LGPL 2.1+') @@ -62,6 +62,23 @@ if cc.get_id() == 'clang' endif endif +if cc.get_id() == 'gcc' + if cc.version().version_compare('<7') + error('gcc version is too old, libcamera requires 7.0 or newer') + endif + + # gcc 7.1 introduced processor-specific ABI breakages related to parameter + # passing on ARM platforms. This generates a large number of messages + # during compilation with gcc >=7.1 until gcc 9. Silence them. + if (host_machine.cpu_family() == 'arm' and + cc.version().version_compare('>=7.1') and + cc.version().version_compare('<9')) + cpp_arguments += [ + '-Wno-psabi', + ] + endif +endif + # We use C99 designated initializers for arrays as C++ has no equivalent # feature. Both gcc and clang support this extension, but recent # versions of clang generate a warning that needs to be disabled. @@ -71,16 +88,6 @@ if cc.has_argument('-Wno-c99-designator') ] endif -# gcc 7.1 introduced processor-specific ABI breakages related to parameter -# passing on ARM platforms. This generates a large number of messages during -# compilation with gcc >=7.1 until gcc 9. Silence them. -if (host_machine.cpu_family() == 'arm' and cc.get_id() == 'gcc' and - cc.version().version_compare('>=7.1') and cc.version().version_compare('<9')) - cpp_arguments += [ - '-Wno-psabi', - ] -endif - c_arguments += common_arguments cpp_arguments += common_arguments