Skip to content

Use C99 designated initialisers for PerlIO_funcs#24390

Open
ilmari wants to merge 1 commit into
bleadfrom
perlio-designated-initialisers
Open

Use C99 designated initialisers for PerlIO_funcs#24390
ilmari wants to merge 1 commit into
bleadfrom
perlio-designated-initialisers

Conversation

@ilmari
Copy link
Copy Markdown
Member

@ilmari ilmari commented Apr 25, 2026

This avoids having to count NULLs for layers that only implement a subset of functions.


  • This set of changes does not require a perldelta entry.

This avoids having to count NULLs for layers that only implement a
subset of functions.
@Leont Leont added the defer-next-dev This PR should not be merged yet, but await the next development cycle label Apr 25, 2026
@tonycoz
Copy link
Copy Markdown
Contributor

tonycoz commented Apr 28, 2026

I think it is a silly warning with designated initializers, but g++ produces a mess of warnings:

g++ -c -DPERL_CORE -fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-nonnull-compare -Wwrite-strings -Wno-use-after-free perlio.c
perlio.c:1031:1: warning: missing initializer for member ‘_PerlIO_funcs::size’ [-Wmissing-field-initializers]
 1031 | };
      | ^
perlio.c:1031:1: warning: missing initializer for member ‘_PerlIO_funcs::Popped’ [-Wmissing-field-initializers]
perlio.c:1031:1: warning: missing initializer for member ‘_PerlIO_funcs::Binmode’ [-Wmissing-field-initializers]
perlio.c:1031:1: warning: missing initializer for member ‘_PerlIO_funcs::Getarg’ [-Wmissing-field-initializers]
... and many more

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:

GCC_DIAG_IGNORE_DECL(-Wmissing-field-initializers);
PERLIO_FUNCS_DECL(PerlIO_remove) = {
     .fsize = sizeof(PerlIO_funcs),
    .name = "pop",
    .kind = PERLIO_K_DUMMY | PERLIO_K_UTF8,
    .Pushed = PerlIOPop_pushed,
    .Open = PerlIOBase_open,
};
GCC_DIAG_RESTORE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

defer-next-dev This PR should not be merged yet, but await the next development cycle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants