From d97be101490a46c72f919d3dc45f4bc06e625e0c Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 7 Feb 2014 11:39:29 +0800 Subject: tools: Fix build on Visual Studio As unistd.h is not universally available, don't include it unconditionally and include the corresponding Windows headers where necessary. Also, use gssize in place of ssize_t and define STDOUT_FILENO on Windows when we don't have unistd.h, which is a constant that is defined in unistd.h. https://bugzilla.gnome.org/show_bug.cgi?id=723813 --- json-glib/json-glib-format.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'json-glib/json-glib-format.c') diff --git a/json-glib/json-glib-format.c b/json-glib/json-glib-format.c index f10cee9..d39b325 100644 --- a/json-glib/json-glib-format.c +++ b/json-glib/json-glib-format.c @@ -23,7 +23,10 @@ #include "config.h" +#ifdef HAVE_UNISTD_H #include +#endif + #include #include #include @@ -33,6 +36,12 @@ #include #include +#if defined (G_OS_WIN32) && !defined (HAVE_UNISTD_H) +#include + +#define STDOUT_FILENO 1 +#endif + static char **files = NULL; static gboolean prettify = FALSE; static int indent_spaces = 2; @@ -89,7 +98,7 @@ format (JsonParser *parser, p = data; while (len > 0) { - ssize_t written = write (STDOUT_FILENO, p, len); + gssize written = write (STDOUT_FILENO, p, len); if (written == -1 && errno != EINTR) { -- cgit v1.2.1