[libcamera-devel] [PATCH] apps: cam: Fix compilation error with clang when libtiff-4 is not found
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Mon Oct 24 15:18:53 CEST 2022
On Mon, Oct 24, 2022 at 12:43:19PM +0100, Kieran Bingham wrote:
> Quoting Laurent Pinchart via libcamera-devel (2022-10-24 11:46:38)
> > When libtiff-4 is not found, the private camera_ member of the FileSink
> > class is set but never used. This causes a compilation error with clang:
> >
> > In file included from ../../src/apps/cam/file_sink.cpp:19:
> > ../../src/apps/cam/file_sink.h:39:27: error: private field 'camera_' is not used [-Werror,-Wunused-private-field]
> > const libcamera::Camera *camera_;
> >
> > Fix by making the camera_ member field conditional on HAVE_TIFF.
>
> Ugh, this feels like an ugly fix. I hate it when compiler warnings
> (which I want to keep enabled) work against us like this.
I tried
[[maybe_unused]] const libcamera::Camera *camera_;
it made clang happy, but gcc choke on it, telling the attribute was
ignored. I Gave up :-)
> Any other proposal is probably just a different ugly workaround on an
> unused arg so lets fix the build and ...
>
> Acked-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
>
> >
> > Fixes: 6404b163bcbb ("cam: file_sink: Add support for DNG output")
> > Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> > ---
> > src/apps/cam/file_sink.cpp | 8 ++++++--
> > src/apps/cam/file_sink.h | 2 ++
> > 2 files changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp
> > index 9d60c04e1cf4..4dfacc103c54 100644
> > --- a/src/apps/cam/file_sink.cpp
> > +++ b/src/apps/cam/file_sink.cpp
> > @@ -21,10 +21,14 @@
> >
> > using namespace libcamera;
> >
> > -FileSink::FileSink(const libcamera::Camera *camera,
> > +FileSink::FileSink([[maybe_unused]] const libcamera::Camera *camera,
> > const std::map<const libcamera::Stream *, std::string> &streamNames,
> > const std::string &pattern)
> > - : camera_(camera), streamNames_(streamNames), pattern_(pattern)
> > + :
> > +#ifdef HAVE_TIFF
> > + camera_(camera),
> > +#endif
> > + streamNames_(streamNames), pattern_(pattern)
> > {
> > }
> >
> > diff --git a/src/apps/cam/file_sink.h b/src/apps/cam/file_sink.h
> > index 9ce8b619f69d..300edf8dc902 100644
> > --- a/src/apps/cam/file_sink.h
> > +++ b/src/apps/cam/file_sink.h
> > @@ -36,7 +36,9 @@ private:
> > libcamera::FrameBuffer *buffer,
> > const libcamera::ControlList &metadata);
> >
> > +#ifdef HAVE_TIFF
> > const libcamera::Camera *camera_;
> > +#endif
> > std::map<const libcamera::Stream *, std::string> streamNames_;
> > std::string pattern_;
> > std::map<libcamera::FrameBuffer *, std::unique_ptr<Image>> mappedBuffers_;
> >
> > base-commit: 24f8ef763a60f410963fd8897a16ae077aaeff0d
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list