Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays

Поиск
Список
Период
Сортировка
От Joe Nelson
Тема Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays
Дата
Msg-id 20191004142837.umvblk237gsz3wfo@begriffs.com
обсуждение исходный текст
Ответ на Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays  (Amit Kapila <amit.kapila16@gmail.com>)
Ответы Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Amit Kapila wrote:
> > How about I just define them both the same?
> > #define INIT_ALL_ELEMS_ZERO     {0}
> > #define INIT_ALL_ELEMS_FALSE    {0}
>
> I think using one define would be preferred, but you can wait and see
> if others prefer defining different macros for the same thing.

+1 on using INIT_ALL_ELEMS_ZERO everywhere, even for bool[].  You may
worry, "Should we really be assigning 0 to something of type bool? Is
that the wrong type or a detail that varies by implementation?" It's
safe though, the behavior is guaranteed to be correct by section 7.16 of
the C99 spec, which says that bool, true, and false are always macros
for _Bool, 1, and 0 respectively.

One might argue that INIT_ALL_ELEMS_FALSE as a synonym for
INIT_ALL_ELEMS_ZERO is good for readability in the same way that "false"
is for 0. However I want to avoid creating the impression that there is,
or can be, a collection of INIT_ALL_ELEMS_xxx macros invoking different
initializer behavior.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Masahiko Sawada
Дата:
Сообщение: Re: [HACKERS] Block level parallel vacuum
Следующее
От: Tomas Vondra
Дата:
Сообщение: Re: Memory Accounting