Use C99 designated initialisers for PerlIO_funcs - #24390
Conversation
This avoids having to count NULLs for layers that only implement a subset of functions.
|
I think it is a silly warning with designated initializers, but g++ produces a mess of warnings: Adding C++ default initializers prevents the warnings but that would be a mess of macros for us. I suspect the best choice would be to suppress the warning: |
|
I encountered this problem of the While it is technically possible to silence the warnings by wrapping them as suggested, I would find this annoyingly verbose to have to remember to do for every C99-style struct initialisation we ever write into our code, just to quiet a warning in the tiny corner-case of us using |
|
Would it work to wrap the suppression in a macro? #define PERLIO_FUNCS_DEF(funcs, ...) \
GCC_DIAG_IGNORE_DECL(-Wmissing-field-initializers); \
PERLIO_FUNCS_DECL(funcs) = { __VA_ARGS__ }; \
GCC_DIAG_RESTOREand then do: PERLIO_FUNCS_DEF(PerlIO_remove,
.fsize = sizeof(PerlIO_funcs),
.name = "pop",
.kind = PERLIO_K_DUMMY | PERLIO_K_UTF8,
.Pushed = PerlIOPop_pushed,
.Open = PerlIOBase_open,
);Ore even a generic #define STRUC_INIT(decl, ...) \
GCC_DIAG_IGNORE_DECL(-Wmissing-field-initializers); \
decl = { __VA_ARGS__ }; \
GCC_DIAG_RESTORE |
|
As the |
|
Now that #24559 is in, this shouldn't cause upsets to |
This avoids having to count NULLs for layers that only implement a subset of functions.