[{"id":32925,"web_url":"https://patchwork.libcamera.org/comment/32925/","msgid":"<20250103145318.GO554@pendragon.ideasonboard.com>","date":"2025-01-03T14:53:18","subject":"Re: [PATCH] libcamera: base: Don't redefine __nodiscard","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Mattijs,\n\nThank you for the patch.\n\nOn Fri, Jan 03, 2025 at 03:02:50PM +0100, Mattijs Korpershoek wrote:\n> Some libc implementations (like bionic) already define the __nodiscard\n> macro [1].\n> \n> Building with bionic results in compiler error since libcamera redefines\n> the __nodiscard macro.\n> \n> Don't redefine __nodiscard if it's already defined.\n\nbionic defines it as __attribute__((__warn_unused_result__)) which\n(hopefully) does the exact same thing as [[nodiscard]]. Someone else\ncould define it differently though. I suppose the risk is low ?\n\n> [1] https://android-review.googlesource.com/c/platform/bionic/+/3254860\n> \n> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\n> ---\n> Hi, it's been a while. I've found a (trivial) build issue when\n> building against recent bionic versions.\n> \n> I hope this is the right fix. Thanks for your review!\n\nIt's been nearly four years since we introduced __nodiscard. I wonder if\nwe could require applications to use C++17 or newer now, and use\n[[nodiscard]] directly.\n\n> ---\n>  include/libcamera/base/compiler.h | 2 ++\n>  1 file changed, 2 insertions(+)\n> \n> diff --git a/include/libcamera/base/compiler.h b/include/libcamera/base/compiler.h\n> index fda8fdfdc543f86c5554e38ef790c00d72d60389..946e20d835b216446e4099b6ab6865638d9aaf26 100644\n> --- a/include/libcamera/base/compiler.h\n> +++ b/include/libcamera/base/compiler.h\n> @@ -7,8 +7,10 @@\n>  \n>  #pragma once\n>  \n> +#ifndef __nodiscard\n>  #if __cplusplus >= 201703L\n>  #define __nodiscard\t\t[[nodiscard]]\n>  #else\n>  #define __nodiscard\n>  #endif\n> +#endif\n> \n> ---\n> base-commit: 35ed4b91291d9f3d08e4b51acfb51163e65df8f8\n> change-id: 20250103-nodiscard-redef-9158e8fdc3f5","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 1724CC324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 Jan 2025 14:53:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1FC95684DF;\n\tFri,  3 Jan 2025 15:53:19 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 24BBB61886\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Jan 2025 15:53:18 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 79323316;\n\tFri,  3 Jan 2025 15:52:28 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ZQtAJJUJ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1735915948;\n\tbh=rz07yOep+gbQacaXAnFVJccZEBDGHefNInjjFMHjAR0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ZQtAJJUJP0GsLaJ1UeGok15bFbZYzMnr/sG5yOExnrJw6fJ+piTIsX8w0aIDA+e0h\n\tmPAu372um7UvwfS06JP91SXBzPhsWojWaUKyDZ6B2viIGHSP00YJuMwtRmV7r+9tta\n\t15zkGYgXYjCGniCqhAXwEnpnBsQ8otvmgs9a+49k=","Date":"Fri, 3 Jan 2025 16:53:18 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Mattijs Korpershoek <mkorpershoek@baylibre.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tGuillaume La Roque <glaroque@baylibre.com>","Subject":"Re: [PATCH] libcamera: base: Don't redefine __nodiscard","Message-ID":"<20250103145318.GO554@pendragon.ideasonboard.com>","References":"<20250103-nodiscard-redef-v1-1-aa7559c8ebe3@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250103-nodiscard-redef-v1-1-aa7559c8ebe3@baylibre.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":32926,"web_url":"https://patchwork.libcamera.org/comment/32926/","msgid":"<87ed1joo5h.fsf@baylibre.com>","date":"2025-01-03T16:30:50","subject":"Re: [PATCH] libcamera: base: Don't redefine __nodiscard","submitter":{"id":153,"url":"https://patchwork.libcamera.org/api/people/153/","name":"Mattijs Korpershoek","email":"mkorpershoek@baylibre.com"},"content":"Hi Laurent,\n\nThank you for the review.\n\nOn ven., janv. 03, 2025 at 16:53, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote:\n\n> Hi Mattijs,\n>\n> Thank you for the patch.\n>\n> On Fri, Jan 03, 2025 at 03:02:50PM +0100, Mattijs Korpershoek wrote:\n>> Some libc implementations (like bionic) already define the __nodiscard\n>> macro [1].\n>> \n>> Building with bionic results in compiler error since libcamera redefines\n>> the __nodiscard macro.\n>> \n>> Don't redefine __nodiscard if it's already defined.\n>\n> bionic defines it as __attribute__((__warn_unused_result__)) which\n> (hopefully) does the exact same thing as [[nodiscard]]. Someone else\n> could define it differently though. I suppose the risk is low ?\n\nMy gut feeling is that the risk is pretty low.\n\n>\n>> [1] https://android-review.googlesource.com/c/platform/bionic/+/3254860\n>> \n>> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\n>> ---\n>> Hi, it's been a while. I've found a (trivial) build issue when\n>> building against recent bionic versions.\n>> \n>> I hope this is the right fix. Thanks for your review!\n>\n> It's been nearly four years since we introduced __nodiscard. I wonder if\n> we could require applications to use C++17 or newer now, and use\n> [[nodiscard]] directly.\n\nI've done a quick sed to use [[nodiscard]] directly and seems to build\nfine as well on android-15.0.0_r7 (AP4A.241205.013).\n\nGiven that meson.build has cpp_std=c++17 and that [[nodiscard]] has been\nintroduced in C++17, should I send a v2 to get rid of __nodiscard and\ncompiler.h ?\n\n>\n>> ---\n>>  include/libcamera/base/compiler.h | 2 ++\n>>  1 file changed, 2 insertions(+)\n>> \n>> diff --git a/include/libcamera/base/compiler.h b/include/libcamera/base/compiler.h\n>> index fda8fdfdc543f86c5554e38ef790c00d72d60389..946e20d835b216446e4099b6ab6865638d9aaf26 100644\n>> --- a/include/libcamera/base/compiler.h\n>> +++ b/include/libcamera/base/compiler.h\n>> @@ -7,8 +7,10 @@\n>>  \n>>  #pragma once\n>>  \n>> +#ifndef __nodiscard\n>>  #if __cplusplus >= 201703L\n>>  #define __nodiscard\t\t[[nodiscard]]\n>>  #else\n>>  #define __nodiscard\n>>  #endif\n>> +#endif\n>> \n>> ---\n>> base-commit: 35ed4b91291d9f3d08e4b51acfb51163e65df8f8\n>> change-id: 20250103-nodiscard-redef-9158e8fdc3f5\n>\n> -- \n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 19AC2C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 Jan 2025 16:30:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 26A4C684DF;\n\tFri,  3 Jan 2025 17:30:54 +0100 (CET)","from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com\n\t[IPv6:2a00:1450:4864:20::42f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CF7F761886\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Jan 2025 17:30:52 +0100 (CET)","by mail-wr1-x42f.google.com with SMTP id\n\tffacd0b85a97d-385e2880606so9114813f8f.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 03 Jan 2025 08:30:52 -0800 (PST)","from localhost ([2a01:cb19:95ba:5000:d6dd:417f:52ac:335b])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-38a1c8289a0sm42157780f8f.7.2025.01.03.08.30.51\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 03 Jan 2025 08:30:51 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=baylibre-com.20230601.gappssmtp.com\n\theader.i=@baylibre-com.20230601.gappssmtp.com\n\theader.b=\"MdfOqkSj\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1735921852;\n\tx=1736526652; darn=lists.libcamera.org; \n\th=mime-version:message-id:date:references:in-reply-to:subject:cc:to\n\t:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=gMnR43RzGtK2CFA2M4iiv2FazPBTo2wJbR8Egr6tRX4=;\n\tb=MdfOqkSjce4X0Hl8Gaxg1vzwUZILUMbsWNo4rZeh8QCUzcZ/6/oIzooNyRCTtqaAir\n\tD84REc7jlQyu8Yllr1a3x66OWmqS74b+4F2VjG5bE++OCjGGLJWVp7yK1CAtDPOksxj/\n\tzzcX0Wi9gkGAFmUp2ueb2Fu4xeIny5UHPPSRXNbXhE4dWRQAO+USMA4mnsfy7G8RHEgs\n\tkEkrD2qkkpVPR9+Sxut4BIzD1nOjDZ2JBbkNjkxgpyxTfODhOzboJBXs55v/Fq3EV06N\n\t8Xrq6FPStHVDI8xFtGNe6Wc6CB2zUXFyeFqocehqo/9GXuFcpZtGx3D18g69w22fXeu4\n\tmg7A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1735921852; x=1736526652;\n\th=mime-version:message-id:date:references:in-reply-to:subject:cc:to\n\t:from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; \n\tbh=gMnR43RzGtK2CFA2M4iiv2FazPBTo2wJbR8Egr6tRX4=;\n\tb=g9zwmMNUd0Irr2INBAmeEeoiBEG42HyS+TakSV2AgDRn6sYn0szWf3cB/ghxy9Ocio\n\tB6VRRqCNRIg4ZOeY86x+Au8t5zVEes5Rb70uf3nCvWQomEvevPH1I09saWurwGCbNVnG\n\tide5dm4xIvYMHSEdvQ7jH02/PXzuF5VY3KUW1/hzVabqzaSl4k0ra9KbeOm4ltkPp2IJ\n\tdgjYOixCJmz+f00BHq9/105EByGIEPddl7vCjFsU9iCSuWDXdKqSbNsXq/G1tQDROPmu\n\t1uv9JBObQsTSwY2RxUqiOuCZ1fQmsp9x3BBxkRpERti6V3Hri+aUYtQkC++3fIE2WXSp\n\tRd9Q==","X-Gm-Message-State":"AOJu0YwDNh+lRQtWIUXNXaPi+D63iAOWCSQkcX8BZ5YyyxxosKUsV9x0\n\tMxjpWNgF2sOzzxzC/d9HUyt6dRhyEhgPUTmeEYs9kEqez+3YMD6QeeLRnI3IDbM=","X-Gm-Gg":"ASbGncsW1LuX9oks44hWSmDgL3fidCOjjsxVU2nNl9+xlFkECW4OibKqk2D0JjZy2K4\n\ts9x5lQF7jn1VWxLtzyedwQUuXR2avZvPDXQcRYaty//MQ9D45voObt21ScJbDVICwvJjrNHFC3R\n\tCa4mV1ugZDIWxb8vRP1fyL8BoeVHfODSbIwzDAPHphEMXhmOlCP7//etYDiK2OfVzD5Kz+cPJll\n\t048Z+b1J0mV02Lw1BOURx24dq/ug0gPvrUccS32b3OAUojO1AVa9TBfIuT012+a6w==","X-Google-Smtp-Source":"AGHT+IGSNlPtb6l6giCxpPhjK2EPNjxOGU+QEd47f3T7XijA7WaMB/VKK5i628sEz7yZjVf67xtzUQ==","X-Received":"by 2002:a05:6000:2ad:b0:386:3a8e:64bd with SMTP id\n\tffacd0b85a97d-38a221f2c6emr48381464f8f.22.1735921852226; \n\tFri, 03 Jan 2025 08:30:52 -0800 (PST)","From":"Mattijs Korpershoek <mkorpershoek@baylibre.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, Guillaume La Roque\n\t<glaroque@baylibre.com>","Subject":"Re: [PATCH] libcamera: base: Don't redefine __nodiscard","In-Reply-To":"<20250103145318.GO554@pendragon.ideasonboard.com>","References":"<20250103-nodiscard-redef-v1-1-aa7559c8ebe3@baylibre.com>\n\t<20250103145318.GO554@pendragon.ideasonboard.com>","Date":"Fri, 03 Jan 2025 17:30:50 +0100","Message-ID":"<87ed1joo5h.fsf@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":32933,"web_url":"https://patchwork.libcamera.org/comment/32933/","msgid":"<20250106085041.GB10308@pendragon.ideasonboard.com>","date":"2025-01-06T08:50:41","subject":"Re: [PATCH] libcamera: base: Don't redefine __nodiscard","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Mattijs,\n\nOn Fri, Jan 03, 2025 at 05:30:50PM +0100, Mattijs Korpershoek wrote:\n> On ven., janv. 03, 2025 at 16:53, Laurent Pinchart wrote:\n> > On Fri, Jan 03, 2025 at 03:02:50PM +0100, Mattijs Korpershoek wrote:\n> >> Some libc implementations (like bionic) already define the __nodiscard\n> >> macro [1].\n> >> \n> >> Building with bionic results in compiler error since libcamera redefines\n> >> the __nodiscard macro.\n> >> \n> >> Don't redefine __nodiscard if it's already defined.\n> >\n> > bionic defines it as __attribute__((__warn_unused_result__)) which\n> > (hopefully) does the exact same thing as [[nodiscard]]. Someone else\n> > could define it differently though. I suppose the risk is low ?\n> \n> My gut feeling is that the risk is pretty low.\n\nOur guts agree.\n\n> >> [1] https://android-review.googlesource.com/c/platform/bionic/+/3254860\n> >> \n> >> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\n> >> ---\n> >> Hi, it's been a while. I've found a (trivial) build issue when\n> >> building against recent bionic versions.\n> >> \n> >> I hope this is the right fix. Thanks for your review!\n> >\n> > It's been nearly four years since we introduced __nodiscard. I wonder if\n> > we could require applications to use C++17 or newer now, and use\n> > [[nodiscard]] directly.\n> \n> I've done a quick sed to use [[nodiscard]] directly and seems to build\n> fine as well on android-15.0.0_r7 (AP4A.241205.013).\n> \n> Given that meson.build has cpp_std=c++17 and that [[nodiscard]] has been\n> introduced in C++17, should I send a v2 to get rid of __nodiscard and\n> compiler.h ?\n\nThe question is whether or not anyone still uses libcamera in a project\ncompiled with C++14. I have tried compiling simple-cam with\ncpp_std=c++14 and it failed due to usage of C++17 features in multiple\nlocations in the libcamera public headers. It should be safe to assume\nnobody uses libcamera with C++14 anymore. Dropping compiler.h therefore\nseems best to me.\n\nIt would be nice if you could send a v2.\n\n> >> ---\n> >>  include/libcamera/base/compiler.h | 2 ++\n> >>  1 file changed, 2 insertions(+)\n> >> \n> >> diff --git a/include/libcamera/base/compiler.h b/include/libcamera/base/compiler.h\n> >> index fda8fdfdc543f86c5554e38ef790c00d72d60389..946e20d835b216446e4099b6ab6865638d9aaf26 100644\n> >> --- a/include/libcamera/base/compiler.h\n> >> +++ b/include/libcamera/base/compiler.h\n> >> @@ -7,8 +7,10 @@\n> >>  \n> >>  #pragma once\n> >>  \n> >> +#ifndef __nodiscard\n> >>  #if __cplusplus >= 201703L\n> >>  #define __nodiscard\t\t[[nodiscard]]\n> >>  #else\n> >>  #define __nodiscard\n> >>  #endif\n> >> +#endif\n> >> \n> >> ---\n> >> base-commit: 35ed4b91291d9f3d08e4b51acfb51163e65df8f8\n> >> change-id: 20250103-nodiscard-redef-9158e8fdc3f5","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 88231C3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Jan 2025 08:50:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6C6C7684E2;\n\tMon,  6 Jan 2025 09:50:44 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8D224608AB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Jan 2025 09:50:42 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F25B155A;\n\tMon,  6 Jan 2025 09:49:50 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"AaZcVcZ7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1736153391;\n\tbh=q5uVrsJu4D4FNL60HUNQr1l/vDRs2gW1BjuprnoVRp4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=AaZcVcZ7QaRtcbKc95UqKhzyVhYPu271GAhYH3zwQ4z5OnFPoKx0+qHg1KC4Git24\n\tmXZNZ+1LP81bR/zSr3lwzJ7zLGfQTMAtV8TWuN76xEHTHEdMX2AU2X01SghOcFlqdX\n\trd0uzV7T7RhOI+OXB5pFg7RUdVmPlVGQ1QMxIegQ=","Date":"Mon, 6 Jan 2025 10:50:41 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Mattijs Korpershoek <mkorpershoek@baylibre.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tGuillaume La Roque <glaroque@baylibre.com>","Subject":"Re: [PATCH] libcamera: base: Don't redefine __nodiscard","Message-ID":"<20250106085041.GB10308@pendragon.ideasonboard.com>","References":"<20250103-nodiscard-redef-v1-1-aa7559c8ebe3@baylibre.com>\n\t<20250103145318.GO554@pendragon.ideasonboard.com>\n\t<87ed1joo5h.fsf@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<87ed1joo5h.fsf@baylibre.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":32934,"web_url":"https://patchwork.libcamera.org/comment/32934/","msgid":"<878qroe0ub.fsf@baylibre.com>","date":"2025-01-06T09:41:16","subject":"Re: [PATCH] libcamera: base: Don't redefine __nodiscard","submitter":{"id":153,"url":"https://patchwork.libcamera.org/api/people/153/","name":"Mattijs Korpershoek","email":"mkorpershoek@baylibre.com"},"content":"Hi Laurent,\n\nOn lun., janv. 06, 2025 at 10:50, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote:\n\n> Hi Mattijs,\n>\n> On Fri, Jan 03, 2025 at 05:30:50PM +0100, Mattijs Korpershoek wrote:\n>> On ven., janv. 03, 2025 at 16:53, Laurent Pinchart wrote:\n>> > On Fri, Jan 03, 2025 at 03:02:50PM +0100, Mattijs Korpershoek wrote:\n>> >> Some libc implementations (like bionic) already define the __nodiscard\n>> >> macro [1].\n>> >> \n>> >> Building with bionic results in compiler error since libcamera redefines\n>> >> the __nodiscard macro.\n>> >> \n>> >> Don't redefine __nodiscard if it's already defined.\n>> >\n>> > bionic defines it as __attribute__((__warn_unused_result__)) which\n>> > (hopefully) does the exact same thing as [[nodiscard]]. Someone else\n>> > could define it differently though. I suppose the risk is low ?\n>> \n>> My gut feeling is that the risk is pretty low.\n>\n> Our guts agree.\n>\n>> >> [1] https://android-review.googlesource.com/c/platform/bionic/+/3254860\n>> >> \n>> >> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\n>> >> ---\n>> >> Hi, it's been a while. I've found a (trivial) build issue when\n>> >> building against recent bionic versions.\n>> >> \n>> >> I hope this is the right fix. Thanks for your review!\n>> >\n>> > It's been nearly four years since we introduced __nodiscard. I wonder if\n>> > we could require applications to use C++17 or newer now, and use\n>> > [[nodiscard]] directly.\n>> \n>> I've done a quick sed to use [[nodiscard]] directly and seems to build\n>> fine as well on android-15.0.0_r7 (AP4A.241205.013).\n>> \n>> Given that meson.build has cpp_std=c++17 and that [[nodiscard]] has been\n>> introduced in C++17, should I send a v2 to get rid of __nodiscard and\n>> compiler.h ?\n>\n> The question is whether or not anyone still uses libcamera in a project\n> compiled with C++14. I have tried compiling simple-cam with\n> cpp_std=c++14 and it failed due to usage of C++17 features in multiple\n> locations in the libcamera public headers. It should be safe to assume\n> nobody uses libcamera with C++14 anymore. Dropping compiler.h therefore\n> seems best to me.\n>\n> It would be nice if you could send a v2.\n\nThanks, done here:\n\nhttps://lists.libcamera.org/pipermail/libcamera-devel/2025-January/047937.html\n\n>\n>> >> ---\n>> >>  include/libcamera/base/compiler.h | 2 ++\n>> >>  1 file changed, 2 insertions(+)\n>> >> \n>> >> diff --git a/include/libcamera/base/compiler.h b/include/libcamera/base/compiler.h\n>> >> index fda8fdfdc543f86c5554e38ef790c00d72d60389..946e20d835b216446e4099b6ab6865638d9aaf26 100644\n>> >> --- a/include/libcamera/base/compiler.h\n>> >> +++ b/include/libcamera/base/compiler.h\n>> >> @@ -7,8 +7,10 @@\n>> >>  \n>> >>  #pragma once\n>> >>  \n>> >> +#ifndef __nodiscard\n>> >>  #if __cplusplus >= 201703L\n>> >>  #define __nodiscard\t\t[[nodiscard]]\n>> >>  #else\n>> >>  #define __nodiscard\n>> >>  #endif\n>> >> +#endif\n>> >> \n>> >> ---\n>> >> base-commit: 35ed4b91291d9f3d08e4b51acfb51163e65df8f8\n>> >> change-id: 20250103-nodiscard-redef-9158e8fdc3f5\n>\n> -- \n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 81A0DC0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Jan 2025 09:41:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3637E684E7;\n\tMon,  6 Jan 2025 10:41:19 +0100 (CET)","from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com\n\t[IPv6:2a00:1450:4864:20::32c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 33FF6684E0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Jan 2025 10:41:18 +0100 (CET)","by mail-wm1-x32c.google.com with SMTP id\n\t5b1f17b1804b1-436345cc17bso102231825e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 06 Jan 2025 01:41:18 -0800 (PST)","from localhost ([2a01:cb19:95ba:5000:d6dd:417f:52ac:335b])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-43661219a08sm568598695e9.25.2025.01.06.01.41.17\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 06 Jan 2025 01:41:17 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=baylibre-com.20230601.gappssmtp.com\n\theader.i=@baylibre-com.20230601.gappssmtp.com\n\theader.b=\"nrSEXGBu\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736156478;\n\tx=1736761278; darn=lists.libcamera.org; \n\th=mime-version:message-id:date:references:in-reply-to:subject:cc:to\n\t:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=cwfJ3FgUfllmG18K1E2qQvnJ8pi63NSE5AxagCkzZp4=;\n\tb=nrSEXGBuBOIyfPyLdAzOQVyfUHFR7rcIjBqoEF4qFZidOlCQAm9w6Dm1ib5F3xh4qt\n\tFZHcMBTRpwsX1jgmC7fvhocUkQUPmPzOqWbCHFE8q71+ATDzwr4mcIUQYRXTgoGK2UKe\n\tKce8OFX34NfcKtmASTtWGKiXfoJvInp9jjTSwLXojqLZwOrzDM5FssoVYGoaXGDuhcNa\n\t8E3UuXzkhGrdkuvnOkDC/OSf+TPiF5XT44FkP1gwUsk4YwRjsdh2mWQD/+QG7zizTzAU\n\tStUdbuVUfyy+iePFRH9N6TyZsVfyfxE8VhwCgfJEZWzoRIIFE0rqViyAs+YcLLwXlLSi\n\tYZiQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1736156478; x=1736761278;\n\th=mime-version:message-id:date:references:in-reply-to:subject:cc:to\n\t:from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; \n\tbh=cwfJ3FgUfllmG18K1E2qQvnJ8pi63NSE5AxagCkzZp4=;\n\tb=pCwDYW/KiR7HQZ6Jxsj9UVCQVi3c2YRqBAZCYd45bN4yKBaMMFd/BS4s4NqvV9uuax\n\tcS/dhnrVzIYF7jD531iufVwtGzOJZbHgtuQo6UosBYzvUerGZT4Plj5t5RcvMEU0GHHy\n\tZuDUxIkJSFZPkxP16EX/YoKRw8qHrGPhLlk7SWnzoUvmr9Me5L/lIwJ6Qr0s7QUvNfdx\n\t//xSNhwnY9JN2dM5326iq/yL+4Nga2ZPNb5FsuUapYt1Itw3BJp7YqpzblHQY9S8NSGu\n\t6U+5Ii1erqCHC6I4lfkr4nvnq/1r0XPFk9OiJNJJxyPJSBOHUS1f81IT0+5Zo9+2GNX/\n\tM+zA==","X-Gm-Message-State":"AOJu0YyklEZDliIMvJgayI9tsWbWpePD20t2zDljWq+uFWdpUOG6Pczo\n\t/wsLCVUfBkaezqt3ML3HOw5rXDZJLNlt4WPLuhqnz+nWRuO//EUwJ7Z/OOiOcSQzQ+w73xCIT7/\n\td","X-Gm-Gg":"ASbGncuId9nE+bCarxGIxsIazNXVOWzRokg7++++886Y+MmhAWEa6/LVjhBec5/o9gx\n\t7PlCjGGPs5X6EzZjaC2jrk+GzG9FkQvXIQz6Xrv/o42tMXOrVELAuMkEG4DAgC/iTmHOB1946lz\n\tbX0MLVTvEI1sSwcuOWHFojxwb27bmte3E7Hv2WBdzKQNoX6/Tpm6P5KmewTrr22yCCJTl1rn7aF\n\tuREoBAv4DP4TakC35FD0H0ll5oWyzF3IRPtOV15ZttL0SB/NsciAVmE1/z50KRwug==","X-Google-Smtp-Source":"AGHT+IGcVW1jM6k5PPdoYHNThX2dz5YV6zx32pI+TmTtSx/DbwzWiTCj5HhSqAlMnZHNEVLfkjVmhg==","X-Received":"by 2002:a5d:5f51:0:b0:385:fa2e:a33e with SMTP id\n\tffacd0b85a97d-38a223fd369mr45350393f8f.43.1736156477586; \n\tMon, 06 Jan 2025 01:41:17 -0800 (PST)","From":"Mattijs Korpershoek <mkorpershoek@baylibre.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, Guillaume La Roque\n\t<glaroque@baylibre.com>","Subject":"Re: [PATCH] libcamera: base: Don't redefine __nodiscard","In-Reply-To":"<20250106085041.GB10308@pendragon.ideasonboard.com>","References":"<20250103-nodiscard-redef-v1-1-aa7559c8ebe3@baylibre.com>\n\t<20250103145318.GO554@pendragon.ideasonboard.com>\n\t<87ed1joo5h.fsf@baylibre.com>\n\t<20250106085041.GB10308@pendragon.ideasonboard.com>","Date":"Mon, 06 Jan 2025 10:41:16 +0100","Message-ID":"<878qroe0ub.fsf@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]