Message112926
Attempting to compile Python 3 extension modules on GCC with "-Wmissing-field-initializers" enabled leads to warnings from the PyModuleDef_HEAD_INIT macro
Seen attempting to build SELinux python bindings against python 3.1 with "-W -Werror", the "-W" implies "-Wmissing-field-initializers":
> cc -Werror -Wall -W -Wundef -Wshadow -Wmissing-noreturn
> > -Wmissing-format-attribute -I../include -I/usr/include -D_GNU_SOURCE
> > -D_FILE_OFFSET_BITS=64 -I/usr/include/python3.1 -fPIC -DSHARED -c -o
> > audit2why.lo audit2why.c
> > cc1: warnings being treated as errors
> > audit2why.c:439: error: missing initializer
> > audit2why.c:439: error: (near initialization for ?moduledef.m_base.m_init¹)
> > make: *** [audit2why.lo] Error 1
The PyModuleDef_HEAD_INIT is intended to initialize m_base within a PyModuleDef, but only explicitly initializes the PyObject_HEAD fields:
#define PyModuleDef_HEAD_INIT {PyObject_HEAD_INIT(NULL)}
typedef struct PyModuleDef_Base {
PyObject_HEAD
PyObject* (*m_init)(void);
Py_ssize_t m_index;
PyObject* m_copy;
} PyModuleDef_Base;
typedef struct PyModuleDef{
PyModuleDef_Base m_base;
const char* m_name;
const char* m_doc;
Py_ssize_t m_size;
PyMethodDef *m_methods;
inquiry m_reload;
traverseproc m_traverse;
inquiry m_clear;
freefunc m_free;
} PyModuleDef;
The attached patch extends it to also explicitly zero the other m_base fields. |
|
Date |
User |
Action |
Args |
2010-08-04 23:43:32 | dmalcolm | set | recipients:
+ dmalcolm |
2010-08-04 23:43:32 | dmalcolm | set | messageid: <1280965412.21.0.0751804906986.issue9518@psf.upfronthosting.co.za> |
2010-08-04 23:43:31 | dmalcolm | link | issue9518 messages |
2010-08-04 23:43:29 | dmalcolm | create | |
|