Skip to content

Commit 08dd543

Browse files
committed
python: do not error out on incompatible function pointer casts
In many cases, the callback function pointers in PyMethodDef definitions are cast to PyCFunction type where as their actual signature matches that of PyCFunctionWithKeywords type. This issue exists throughout in python 2.7 codebase in general. On newer compilers, this produces a compile time failure like the following: build/grub/grub-core/contrib/python/bitsmodule.c:558:16: error: cast between incompatible function types from 'PyObject * (*)(PyObject *, PyObject *, PyObject *)' {aka 'struct _object * (*)(struct _object *, struct _object *, struct _object *)'} to 'PyObject * (*)(PyObject *, PyObject *)' {aka 'struct _object * (*)(struct _object *, struct _object *)'} [-Werror=cast-function-type] 558 | {"get_xy", (PyCFunction)bits_get_xy, METH_KEYWORDS, "get_xy(term) -> (cursor_x, cursor_y)"}, Pass -Wno-cast-function-type in compiler cflags in order to suppress this failure. Signed-off-by: Ani Sinha <[email protected]>
1 parent 3cfe27c commit 08dd543

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rc/python/Makefile.core.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
module = {
3030
name = python;
3131
cppflags = '-I$(top_srcdir)/contrib/python -I$(srcdir)/contrib-deps/python/Include -D_IEEE_LIBM -D__LITTLE_ENDIAN= -I$(srcdir)/contrib-deps/fdlibm $(CONTRIB_CPPFLAGS) -include contrib/acpica/acenv.h -DGRUB2 -DACPI_LIBRARY -I$(top_srcdir)/contrib/acpica -I$(srcdir)/contrib-deps/acpica/source/include -U__ELF__ -I$(srcdir)/contrib-deps/libffi/include -I$(srcdir)/contrib-deps/libffi/src/x86 -I$(srcdir)/contrib-deps/python/Modules/zlib';
32-
cflags = '$(CONTRIB_CFLAGS) -fshort-wchar -maccumulate-outgoing-args -Wno-empty-body -Wno-float-equal -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-missing-declarations -Wno-missing-format-attribute -Wno-missing-noreturn -Wno-missing-prototypes -Wno-nested-externs -Wno-old-style-definition -Wno-parentheses -Wno-redundant-decls -Wno-sign-compare -Wno-shadow -Wno-shift-negative-value -Wno-type-limits -Wno-undef -Wno-uninitialized -Wno-unused -Wno-unused-parameter -Wno-unused-value -Wno-unused-variable -Wno-write-strings';
32+
cflags = '$(CONTRIB_CFLAGS) -fshort-wchar -Wno-cast-function-type -maccumulate-outgoing-args -Wno-empty-body -Wno-float-equal -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-missing-declarations -Wno-missing-format-attribute -Wno-missing-noreturn -Wno-missing-prototypes -Wno-nested-externs -Wno-old-style-definition -Wno-parentheses -Wno-redundant-decls -Wno-sign-compare -Wno-shadow -Wno-shift-negative-value -Wno-type-limits -Wno-undef -Wno-uninitialized -Wno-unused -Wno-unused-parameter -Wno-unused-value -Wno-unused-variable -Wno-write-strings';
3333
enable = i386_pc;
3434
enable = i386_efi;
3535
enable = x86_64_efi;

0 commit comments

Comments
 (0)