From 1571aef9cc761ffa88da096fc09bd214f3e372c9 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 15 Dec 2012 18:06:11 +0000 Subject: [PATCH] python: Enable C compiler warnings. --- generator/python.ml | 10 ++++++++++ python/Makefile.am | 2 +- python/guestfs-py-byhand.c | 6 ++++++ python/guestfs-py.h | 3 --- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/generator/python.ml b/generator/python.ml index 0966686b5..8752fd3c9 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -35,6 +35,12 @@ let rec generate_python_c () = generate_header CStyle LGPLv2plus; pr "\ +/* This has to be included first, else definitions conflict with + * glibc header files. Python is broken. + */ +#define PY_SSIZE_T_CLEAN 1 +#include + #include #include @@ -567,12 +573,16 @@ moduleinit (void) } #if PY_MAJOR_VERSION >= 3 +extern PyMODINIT_FUNC PyInit_libguestfsmod (void); + PyMODINIT_FUNC PyInit_libguestfsmod (void) { return moduleinit (); } #else +extern void initlibguestfsmod (void); + void initlibguestfsmod (void) { diff --git a/python/Makefile.am b/python/Makefile.am index 8000f1c69..d03bfcf68 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -42,7 +42,7 @@ python_LTLIBRARIES = libguestfsmod.la libguestfsmod_la_SOURCES = guestfs-py.c guestfs-py.h guestfs-py-byhand.c libguestfsmod_la_CFLAGS = \ -DGUESTFS_PRIVATE_FUNCTIONS=1 \ - -Wall \ + $(WARN_CFLAGS) $(WERROR_CFLAGS) \ -I$(PYTHON_INCLUDEDIR) \ -I$(top_srcdir)/src -I$(top_builddir)/src libguestfsmod_la_LIBADD = $(top_builddir)/src/libguestfs.la diff --git a/python/guestfs-py-byhand.c b/python/guestfs-py-byhand.c index 5edaaf2da..3f2e637d5 100644 --- a/python/guestfs-py-byhand.c +++ b/python/guestfs-py-byhand.c @@ -21,6 +21,12 @@ * guestfs-py.c). */ +/* This has to be included first, else definitions conflict with + * glibc header files. Python is broken. + */ +#define PY_SSIZE_T_CLEAN 1 +#include + #include #include diff --git a/python/guestfs-py.h b/python/guestfs-py.h index e2ca6e33d..da4e4e8a9 100644 --- a/python/guestfs-py.h +++ b/python/guestfs-py.h @@ -21,9 +21,6 @@ #include "guestfs.h" -#define PY_SSIZE_T_CLEAN 1 -#include - #if PY_VERSION_HEX < 0x02050000 typedef int Py_ssize_t; #define PY_SSIZE_T_MAX INT_MAX