[json-glib] tools: Fix build on Visual Studio
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [json-glib] tools: Fix build on Visual Studio
- Date: Fri, 7 Feb 2014 10:59:28 +0000 (UTC)
commit d97be101490a46c72f919d3dc45f4bc06e625e0c
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Fri Feb 7 11:39:29 2014 +0800
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 ++++++++++-
json-glib/json-glib-validate.c | 2 ++
2 files changed, 12 insertions(+), 1 deletions(-)
---
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 <unistd.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
@@ -33,6 +36,12 @@
#include <glib/gi18n.h>
#include <json-glib/json-glib.h>
+#if defined (G_OS_WIN32) && !defined (HAVE_UNISTD_H)
+#include <io.h>
+
+#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)
{
diff --git a/json-glib/json-glib-validate.c b/json-glib/json-glib-validate.c
index 97bd53d..2eb013a 100644
--- a/json-glib/json-glib-validate.c
+++ b/json-glib/json-glib-validate.c
@@ -23,7 +23,9 @@
#include "config.h"
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]