[libcamera-devel] [PATCH 01/17] meson: Allow partially initializing objects

Kieran Bingham kieran.bingham at ideasonboard.com
Wed May 29 23:13:58 CEST 2019


Hi Niklas, Jacopo,

On 27/05/2019 10:18, Jacopo Mondi wrote:
> Hi Niklas,
> 
> On Mon, May 27, 2019 at 02:15:27AM +0200, Niklas Söderlund wrote:
>> There are valid use-cases where one might wish to partially initialize a
>> structure when creating it without needing to initialize all members.
>> This is especially common when working with V4L2.
>>
>> struct foo {
>>     int bar;
>>     int baz;
>> };
>>
>> struct foo f = {
>>     .bar = 1;
>> };
>>
>> Without -Wno-missing-field-initializers fails to compile with the error,
> 
> I asked for the same a few weeks ago, so I welcome this change
> Acked-by: Jacopo Mondi <jacopo at jmondi.org>

I was uncertain before, but I can't deny it would be useful to simplify
code /iff/ you know certain members do not need to be initialised.

We'll have to watch our reviews more closely on initialising structures :-)


Acked-by: Kieran Bingham <kieran.bingham at ideasonboard.com>

>>
>>     error: missing initializer for member ‘foo::baz’ [-Werror=missing-field-initializers]
>>
>> Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
>> ---
>>  meson.build | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/meson.build b/meson.build
>> index 4d3e99d3e58f71d5..90ad58328f9a2bd5 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -22,6 +22,7 @@ endif
>>
>>  common_arguments = [
>>      '-Wno-unused-parameter',
>> +    '-Wno-missing-field-initializers',
>>      '-include', 'config.h',
>>  ]
>>
>> --
>> 2.21.0
>>
>> _______________________________________________
>> libcamera-devel mailing list
>> libcamera-devel at lists.libcamera.org
>> https://lists.libcamera.org/listinfo/libcamera-devel
>>
>> _______________________________________________
>> libcamera-devel mailing list
>> libcamera-devel at lists.libcamera.org
>> https://lists.libcamera.org/listinfo/libcamera-devel

-- 
Regards
--
Kieran


More information about the libcamera-devel mailing list