[libcamera-devel] [PATCH] libcamera: pipeline: fix c++20 compile warning

Laurent Pinchart laurent.pinchart at ideasonboard.com
Tue Nov 14 14:42:19 CET 2023


On Tue, Nov 14, 2023 at 12:53:04PM +0200, Laurent Pinchart via libcamera-devel wrote:
> Hi Brett,
> 
> Thank you for your first libcamera patch :-)
> 
> On Mon, Nov 13, 2023 at 09:52:44AM -0700, Brett Brotherton via libcamera-devel wrote:
> > fix -Wdeprecated-this-capture error when building with c++20 by
> > explicity naming this in the capture
> 
> Nitpicking, s/fix/Fix/ and s/capture$/capture./
> 
> No need to resend the patch for this, I'll update the commit message
> before pushing.
> 
> Is this the only occurrence of implicit *this capture ? I'm happy we're
> not doing that bad :-)
> 
> > Signed-off-by: Brett Brotherton <bbrotherton at google.com>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> 
> I will run this through build testing and push the patch if no issues
> are found.

Unfortunately problems have been found :-(

../../src/libcamera/pipeline_handler.cpp:652:40: error: explicit capture of 'this' with a capture default of '=' is a C++20 extension [-Werror,-Wc++20-extensions]
        media->disconnected.connect(this, [=, this]() { mediaDeviceDisconnected(media); });
                                              ^

> > ---
> >  src/libcamera/pipeline_handler.cpp | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
> > index 9c74c6cf..2220cb92 100644
> > --- a/src/libcamera/pipeline_handler.cpp
> > +++ b/src/libcamera/pipeline_handler.cpp
> > @@ -649,7 +649,7 @@ void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera)
> >   */
> >  void PipelineHandler::hotplugMediaDevice(MediaDevice *media)
> >  {
> > -	media->disconnected.connect(this, [=]() { mediaDeviceDisconnected(media); });
> > +	media->disconnected.connect(this, [=, this]() { mediaDeviceDisconnected(media); });
> >  }
> >  
> >  /**

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list