[libcamera-devel] [PATCH] meson.build: Silence the C99 designators warning

Laurent Pinchart laurent.pinchart at ideasonboard.com
Thu Feb 13 11:52:08 CET 2020


Hi Kieran,

On Thu, Feb 13, 2020 at 10:35:37AM +0000, Kieran Bingham wrote:
> On 12/02/2020 23:54, Laurent Pinchart wrote:
> > We use array designators for array initialization, which is a C99
> > extension. clang-10 warns about it, causing a build failure.
> > 
> > As this is a useful extension, silence the warning. This needs to be
> > done only if the compiler supports the -Wno-c99-designator argument,
> > otherwise a -Wunknown-warning-option will be generated.
> > 
> 
> As we actively use the feature, why not then set the standard
> appropriately instead...
> 
> index 0bbd24b2a295..7d572fa9a47a 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -5,6 +5,7 @@ project('libcamera', 'c', 'cpp',
>          'werror=true',
>          'warning_level=2',
>          'cpp_std=c++14',
> +        'c_std=c99',          # or =c11, or higher if desired [0]
>      ],
>      license : 'LGPL 2.1+')
> 
> Or will that not apply because we're using C++ compilers... but then if
> that's the case, why is our c++ compiler complaining about C features...

The option is indeed for C sources only. I'm not sure what the rationale
is for clang++ to complain about this, but it does.

For what it's worth, ChromeOS also sets -Wno-c99-designator.

> [0] https://mesonbuild.com/Builtin-options.html#compiler-options
> 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> > ---
> >  meson.build | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/meson.build b/meson.build
> > index 0bbd24b2a295..aceba997aebd 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -60,6 +60,12 @@ if cc.get_id() == 'clang'
> >      endif
> >  endif
> >  

I'll add a comment here:

# 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.

> > +if cc.has_argument('-Wno-c99-designator')
> > +    common_arguments += [
> > +        '-Wno-c99-designator',
> > +    ]
> > +endif
> > +
> >  c_arguments += common_arguments
> >  cpp_arguments += common_arguments
> >  

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list