When running GCC with warnings the compiler can warn about incomplete structure initializers. This gives spurious warnings when initializing a PyModuleDef structure using PyModuleDef_HEAD_INIT The attached patchs changes PyModuleDef_HEAD_INIT to explicitly initialize all fields in PyModuleDef_Base. An example warning that is silenced by this patch: Modules/objc/test/structpointer2.m:19: warning: missing initializer Modules/objc/test/structpointer2.m:19: warning: (near initialization for ‘mod_module.m_base.m_init’)
This patch looks good to me, after digging through the relevant module code. I was confused though for a bit as to why PyModuleDef is a PyObject with a NULL type. It turns out that import.c wants to keep them in a dictionary, so it needs to be able to cast to PyObject* and to access the refcount. It never needs the type, though, so it's safe to leave it NULL. I think it might be worth adding comments explaining that in this patch or another.