◐ Shell
clean mode source ↗

Message 416253 - Python tracker

If I build a C++ extension with -std=c++20, I get a compiler error on PyModuleDef_HEAD_INIT:

Modules/_testcppext.cpp:419:5: error: either all initializer clauses should be designated or none of them should be
  419 |     .m_name = "_testcppext",
      |     ^

Code:
---
static struct PyModuleDef module = {
    PyModuleDef_HEAD_INIT,
    .m_name = "_testcppext",
    .m_doc = module_doc,
    ...
};
---

Macro defined as (simplified code):
---
#define PyObject_HEAD_INIT(type) \
    { 1, type },

#define PyModuleDef_HEAD_INIT { \
    PyObject_HEAD_INIT(NULL)    \
    NULL, /* m_init */          \
    0,    /* m_index */         \
    NULL, /* m_copy */          \
  }
---