Skip to content

Commit c78b5a0

Browse files
[3.15] gh-149044: Avoid C++ warnings in PySlot_END macro (GH-158866) (#158965)
gh-149044: Avoid C++ warnings in PySlot_END macro (GH-158866) Initialize all fields in the macro. Otherwise, g++ -Wall -Wextra complains that some fields are not initialized [-Werror=missing-field-initializers]: error: missing initializer for member ‘PySlot::sl_flags’ error: missing initializer for member ‘PySlot::<anonymous>’ error: missing initializer for member ‘PySlot::<anonymous>’ (cherry picked from commit ba9d96f) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 4c6a394 commit c78b5a0

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎Include/slots.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct PySlot {
4242
#define PySlot_STATIC_DATA(NAME, VALUE) \
4343
{.sl_id=(NAME), .sl_flags=PySlot_STATIC, .sl_ptr=(VALUE)}
4444

45-
#define PySlot_END {0}
45+
#define PySlot_END {0, 0, {0}, {_Py_NULL}}
4646

4747

4848
// Macros without designated initializers (for C++11 and below):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix the :c:macro:`PySlot_END` macro for C++: initialize all members to avoid
2+
compiler warnings. Patch by Victor Stinner.

0 commit comments

Comments
 (0)