perl5
perl5 copied to clipboard
Use C99 named initialisers in core structs that define MGVTBLs
Since most Magic vtables do not provide every function, using C99 named initialisers allows us to more easily specify which ones are present, so readers don't have to count commas. Additionally provides a layer of robustness in case more functions are added in future.
(No rush before 5.39.9 but I would like to test this out at least, sometime before too long)
I thought we couldn't use this in public headers because C++?
I thought we could use this in public headers because C++?
Ugh; it's mg_vtable.h, indeed. Does that still count? Even if we can't use it there, I'd still like to do the .c files.
I thought we could use this in public headers because C++?
Ugh; it's
mg_vtable.h, indeed. Does that still count? Even if we can't use it there, I'd still like to do the .c files.
It gets included in perl.h, so yes. But having it for the hand-written ones in .c files is still a big win.
I thought we could use this in public headers because C++?
Ugh; it's
mg_vtable.h, indeed. Does that still count? Even if we can't use it there, I'd still like to do the .c files.
Another option would be to generate a separate mg_vtable.c with the initializations.
The DOINIT code doesn't appear usable outside of the executable/libperl.so since the magic functions are marked hidden.
@leonerd, Given where we are in our annual production cycle, are you thinking of this for 5.40 or 5.42?
@leonerd, Given where we are in our annual production cycle, are you thinking of this for 5.40 or 5.42?
Oh it doesn't need to be in 5.40 at all; it isn't doing any kind of user-benefit change. It's purely tidying up the code internally for our benefit. It can wait for 5.42, I just happen to have started writing it now.
The
DOINITcode doesn't appear usable outside of the executable/libperl.so since the magic functions are marked hidden.
Looking more closely at things, DOINIT is only defined in INTERN.h, which is only included in globals.c, so even though mg_vtable.h is included in perl.h, that only causes the extern declarations to be visible outside globals.c, so we could change the generated code after all.