From patchwork Wed May 13 09:12:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 3783 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5EBE5603DE for ; Wed, 13 May 2020 11:09:43 +0200 (CEST) Received: from localhost.localdomain (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 9ABDD10001D; Wed, 13 May 2020 09:09:42 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 13 May 2020 11:12:55 +0200 Message-Id: <20200513091255.7109-1-jacopo@jmondi.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: controls: Replace array designated initializer 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: , X-List-Received-Date: Wed, 13 May 2020 09:09:43 -0000 Since version 10.0 the LLVM clang++ compiler emits warning to report usage of array designated initializer, a C99 feature that was only supported through an extension of the compiler and will be not valid anymore in C++20. >From https://releases.llvm.org/10.0.0/tools/clang/docs/ReleaseNotes.html The new warnings -Wc99-designator and -Wreorder-init-list warn about uses of C99 initializers in C++ mode for cases that are valid in C99 but not in C++20. This generates the following build error in the controls.cpp file: ../src/libcamera/controls.cpp:54:2: error: array designators are a C99 extension [-Werror,-Wc99-designator] [ControlTypeNone] = 0, ^~~~~~~~~~~~~~~~~ Fix this by replacing the plain C array with an std:map<>. Signed-off-by: Jacopo Mondi --- I would have liked the map to be immutable, but I can't due to missing overloading for operator[]: error: no viable overloaded operator[] for type 'const std::map' Tested with clang++ 10.0.0 and g++ 9.3.0.1 --- src/libcamera/controls.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) -- 2.26.2 diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 08df7f29e938..eaef45a5f62c 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -50,16 +51,16 @@ LOG_DEFINE_CATEGORY(Controls) namespace { -static constexpr size_t ControlValueSize[] = { - [ControlTypeNone] = 0, - [ControlTypeBool] = sizeof(bool), - [ControlTypeByte] = sizeof(uint8_t), - [ControlTypeInteger32] = sizeof(int32_t), - [ControlTypeInteger64] = sizeof(int64_t), - [ControlTypeFloat] = sizeof(float), - [ControlTypeString] = sizeof(char), - [ControlTypeRectangle] = sizeof(Rectangle), - [ControlTypeSize] = sizeof(Size), +std::map ControlValueSize = { + { ControlTypeNone, 0 }, + { ControlTypeBool, sizeof(bool) }, + { ControlTypeByte, sizeof(uint8_t) }, + { ControlTypeInteger32, sizeof(int32_t) }, + { ControlTypeInteger64, sizeof(int64_t) }, + { ControlTypeFloat, sizeof(float) }, + { ControlTypeString, sizeof(char) }, + { ControlTypeRectangle, sizeof(Rectangle) }, + { ControlTypeSize, sizeof(Size) }, }; } /* namespace */