Python and C++20

C++20 limits on the way in which structures can be filled with data. Either you must provide all variables in order, or by field name. You cannot do both. Unfortunately, the Python C API uses some macros to fill the PyModuleDef struct and they use order based filling. Usually, referencing by field name is used by the Python module developer because it delivers more readable and less verbose code. Since C+20, however, this does not compile.

The fix is show below.

Old code:

static PyModuleDef LunaModule = {
    PyModuleDef_HEAD_INIT,
    .m_name = "MyModule",
    .m_doc = "MyModule is awesome",
    .m_size = -1,
    .m_methods = MyMethods
};

New code:

static PyModuleDef LunaModule = {
    .m_base = PyModuleDef_HEAD_INIT,
    .m_name = "MyModule",
    .m_doc = "MyModule is awesome",
    .m_size = -1,
    .m_methods = MyMethods
};