[libvirt] [PATCH] domtop: Fix build on mingw

Firstly, there's no sigaction() nor struct sigaction on mingw. We have to use the one implemented by gnulib (and hence link with gnulib). Then, for some reason one header file from windows defines ERROR symbol. Yes it does. Sigh. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- examples/domtop/Makefile.am | 6 ++++-- examples/domtop/domtop.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/examples/domtop/Makefile.am b/examples/domtop/Makefile.am index c5cb6c7..dbebb46 100644 --- a/examples/domtop/Makefile.am +++ b/examples/domtop/Makefile.am @@ -16,9 +16,11 @@ ## License along with this library. If not, see ## <http://www.gnu.org/licenses/>. -INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include +INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ + -I$(top_builddir)/gnulib/lib -I$(top_srcdir)/gnulib/lib \ + -I$(top_srcdir) LDADDS = $(STATIC_BINARIES) $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la \ - $(COVERAGE_LDFLAGS) + $(top_builddir)/gnulib/lib/libgnu.la $(COVERAGE_LDFLAGS) noinst_PROGRAMS=domtop diff --git a/examples/domtop/domtop.c b/examples/domtop/domtop.c index 4ac7889..af5da46 100644 --- a/examples/domtop/domtop.c +++ b/examples/domtop/domtop.c @@ -20,6 +20,8 @@ * Author: Michal Privoznik <mprivozn@redhat.com> */ +#include <config.h> + #include <errno.h> #include <getopt.h> #include <libvirt/libvirt.h> @@ -35,6 +37,21 @@ static bool debug; static bool run_top; +/* On mingw, there's a header file that poisons the well: + * + * + * CC domtop.o + *domtop.c:40:0: warning: "ERROR" redefined [enabled by default] + * #define ERROR(...) \ + * ^ + *In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/windows.h:71:0, + * from /usr/i686-w64-mingw32/sys-root/mingw/include/winsock2.h:23, + * from ../../gnulib/lib/unistd.h:48, + * from domtop.c:35: + * /usr/i686-w64-mingw32/sys-root/mingw/include/wingdi.h:75:0: note: this is the location of the previous definition + * #define ERROR 0 + */ +#undef ERROR #define ERROR(...) \ do { \ fprintf(stderr, "ERROR %s:%d : ", __FUNCTION__, __LINE__); \ -- 1.8.5.5

On 07/21/2014 09:30 AM, Michal Privoznik wrote:
Firstly, there's no sigaction() nor struct sigaction on mingw. We have to use the one implemented by gnulib (and hence link with gnulib). Then, for some reason one header file from windows defines ERROR symbol. Yes it does. Sigh.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- examples/domtop/Makefile.am | 6 ++++-- examples/domtop/domtop.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Michal Privoznik